Implemented thread handling for WaitForMultipleObjects.
Implemented thread specific functions.
Now using thread_launcher function to properly clean up thread resources at exit.
Removed noreturn from ExitThread, does not conform to http://msdn.microsoft.com/en-us/library/windows/desktop/ms682659%28v=vs.85%29.aspx and crashes FreeRDP.
Preferring exit code from ExitThread now over thread function return.
Fixed thread handle cleanup, checking for resource cleanup now before resetting flags.
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.
Fixed merge errors.
Fixed missing includes and typo.
Locking thread until joined now, preventing multiple joins and race conditions.
Fixed unlocking if pthread_join fails.
Merge pull request #1964 from akallabeth/thread-wait-support

Implemented thread handling for WaitForMultipleObjects.