This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Yield method

 
kumar bangali
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please consider this piece of code
class Testthread2 extends Thread
{
public void run()
{
System.out.println("starting");
yield();
System.out.println("done");
}
}
public static void main(String args[])
{
Testthread2 tt = new Testthread2;
tt.start;
}
In this example should the yield method not be in a try catch block since the thread gets interrupted by yield?
 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The yield() method does not throw an exception, so therefore it needn't be in a try block.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic