Home > Back-end >  STD: : thread
STD: : thread

Time:10-10

Using detach start more child threads, wait for the child how to make the main thread is done? Using the join will block the main thread, unable to start more child threads at the same time,

CodePudding user response:

All threads started first, and then we will go to join
Or create a semaphore group, wait for all semaphore

CodePudding user response:

Create a thread, the execution of the STD: : thread th (function), thread th began to start,

Th. In the main thread calls the join (), as the main thread to block, waiting for the child thread th execution after return, continue, until the end of the main thread,

Th. In the main thread calls detach (), when the child thread th separated from the main thread, the main thread of their thread th control of the child thread th management control by the system background, and by its release thread related resources,
  • Related