Thread: Thread killing
View Single Post
  #10 (permalink)  
Old 09-25-2008, 08:38 PM
masijade masijade is offline
Senior Member
 
Join Date: Jun 2008
Posts: 549
masijade is on a distinguished road
An example of the other way
Code:
public class Bogus2 { public static void main (String[] args) { Thread t = new Thread( new Runnable() { public void run() { int i = 0; while (!Thread.interrupted()) { System.out.println(i++); } } }); t.start(); try { Thread.sleep(50); } catch (InterruptedException ie) {} t.interrupt(); } }
And, BTW, there's no reason why the methods can't be combined (directed at the OP, not you Norm).

Last edited by masijade : 09-25-2008 at 08:51 PM. Reason: Made it simpler
Reply With Quote