Thread: Thread killing
View Single Post
  #3 (permalink)  
Old 09-25-2008, 01:02 PM
masijade masijade is offline
Senior Member
 
Join Date: Jun 2008
Posts: 549
masijade is on a distinguished road
Code:
public class Bogus { public static void main (String[] args) { Thread t = new Thread( new Runnable() { public void run() { try { Thread.sleep(5000); // 5 seconds } catch (InterruptedException ie) { System.out.println("Interrupted, exiting"); // perform whatever cleanup is needed } } }); t.start(); try { Thread.sleep(1000); } catch (InterruptedException ie) {} t.interrupt(); } }
Reply With Quote