• Post Reply Bookmark Topic Watch Topic
  • New Topic

join() ?  RSS feed

 
Gregory Garrison
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to all that I've read join() should prevent a method from moving to the next line until the active thread returns. However, I just read an article which states that depending on the operating system two threads such as
thread1.join()
thread2.join(),
where thread1 and thread2 access the same runnable object, could yeild unpredictable results. Can anyone clarify this for me please.
gg - SCJP2
[This message has been edited by Gregory Garrison (edited December 20, 2001).]
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give a link or reference to the article?
- Peter
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it might be in reference to if you do
thread1.start();
thread2.start();
thread1.join();
thread2.join();
I've seen this before also. If you're system uses the ol' round-robin routine, and this is in main(), your main thread is is halted until those two threads complete, but you cannot say for certain how those two threads will act in regards towards each other. You would instead want to do
thread1.start();
thread1.join();
thread2.start();
thread2.join();
Someone else could probably take the explaination a bit further.
Jason
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!