Wednesday, 15 September 2010

Mechanism of join() in multithreading -


I was studying about multi-threading and came on join .

As I think right, the process ends by using join () on the thread until the 'connected' thread ends She goes. For example, waiting for a call from main in t1.join () to work in main threads t1 End ends and ends with t1 .

I'm curious how the function How to Join () makes it possible - How does it create an existing thread? 'Inside the function? Do the execution of threads included in the join () function should first wait for another thread to finish that thread? Or, is there any way to communicate between two threads (thread which is join and thread which is connected)?

I am looking forward to the answer. Thanks a lot!

You need to be able to wait at some event to join.

  Join the function (T: thread) // atomically if it is already awaiting the end of the return event.  

Waiting can be done in one of two ways:

  1. The incident is moving and is checking from time to time (busy wait)
  2. System To retrieve thread resources and be awake on a system event, in which case the thread is set by the OS scheduler Is managed by

No comments:

Post a Comment