Closing thread handles from within
When a thread is created, a handle is returned which should be closed when its not used anymore.
Can that handle be closed from within the thread function?
My C++ thread class requires this to be possible, and I also think that it is legal and can be done.
DWORD WINAPI Petter::Thread::threadProc( void* lpData )
//Get the startup data for this thread
ThreadStartupData* threadData = reinterpret_cast<ThreadStartupData*>( lpData );
//Obtain a pointer to the thread
Thread* thread = threadData->thisPtr;
//Save the handle in the thread object
thread->threadHandle = threadData->threadHandle;
//Run the thread's main function
//Close the thread's handle
//WARNING: Can this be done inside the thread?
//Delete the thread object