Thursday 25 June 2020

Multithreading: 2.Join and Joinable

Most of the times the main thread may execute in a shorter period of time than the child threads.
If the main thread completes before the child thread, then the child thread will be orphaned.
The main thread needs to wait for the child thread to complete.
We need to call t1.join() on the thread instance to make the main thread wait till t1 execution is complete.


Also we need to check if a thread is joinable (thread with active code of execution), before calling join.

No comments:

Post a Comment