Fixed thread cleanup, now saving state of started flag, setting event and
then cleaning up the thread resources.
Removed WaitForSingleObject in reset_event, joining thread when not allowed.
Added funcion name to debug messages.
Fixed setting of started flag for threads.
pthred_exit now used correct return value argument.
Return value now also set when terminating thread.
Added additional tests for WaitForSingleObject and WaitForMultipleObjects.
Error messages now prefixed with function name.
Implemented bWaitAll for WaitForMultipleObjects.
pthread_join now only called on first wait event, later ones skip this to avoid undefined behavior.
Added joined flag.
Setting exited flag in TerminateThread now to allow setting return code.
Fixed typo
Fixed ExitThread, now running pthread_exit and setting event.