Wait for threads to exit when destroying them.

Bug 19868861

Android does not support canceling threads, but we shouldn't forcefully
destroy them anyway, and we already join() all threads before deleting
them. So use the same semantics on all platforms and join redundantly.

Change-Id: I888e2e64288cf3ac53d570d517f3e0867b8c479e
Reviewed-on: https://swiftshader-review.googlesource.com/2667
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Greg Hartman <ghartman@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Common/Thread.cpp b/src/Common/Thread.cpp
index 298cba0..9db3b48 100644
--- a/src/Common/Thread.cpp
+++ b/src/Common/Thread.cpp
@@ -29,11 +29,7 @@
 
 	Thread::~Thread()
 	{
-		#if defined(_WIN32)
-			CloseHandle(handle);
-		#else
-			pthread_cancel(handle);
-		#endif
+		join();   // Make threads exit before deleting them to not block here
 	}
 
 	void Thread::join()