Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

join()

 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guyz.I have not understand the function of join().A/C to me it waits to join the curently running thread to which it is joined.
If it is correct then plz. explain it
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The join() method is an instance method of the Thread class. So when a running thread (A) calls the join method on another thread (B).It (A) waits until that thread (B) dies before it proceeds.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In practical terms:- say you need to do two time-consuming, I/O bound jobs A and B. Say they are implemented in two Runnable classes A and B. You need both to be finished in order to carry on.
Because they are I/O bound, it makes a lot of sense to run A and B in parallel using threads:The b.join() statement ensures that the doWork method will only return once both job A and job B have been finished.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic