This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Yield method

 
kumar bangali
Greenhorn
Posts: 27
  • 0
  • 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
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic