Waiting for Threads to Finish

Top  Previous  Next

The thread creation functions all return a handle value. A different thread can use this handle with the function thread_wait to wait for the thread to terminate:

 

THREAD_HANDLE h = thread_new(MyThread,...);

...

thread_wait(h); // wait until the thread stops

 

// (the instance of MyThread returns or executes thread_stop).