• Post Reply Bookmark Topic Watch Topic
  • New Topic

use of join() and yeild() method  RSS feed

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the significance of the join and yeild methods in the threads?how and when are they used?
 
Tom Purl
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
join() allows you to wait until one thread is done before another can continue. So, let's assume that Thread object test1 is the current thread of execution. If the following code is executed:

...The test1 will have to wait until test2 is dead before it can continue running.
yeild(), theoretically, allows you to force the current thread of execution to take a break while a thread of equal importance is given a chance to run. I've heard that this isn't the most reliable method in the world, but others may disagree.
[ May 06, 2003: Message edited by: Tom Purl ]
[ May 06, 2003: Message edited by: Tom Purl ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!