public class InterruptedExcept { public static void main(String[] args) throws InterruptedException { Thread thread = new SampleThread(); thread.start(); thread.interrupt(); thread.join(); } } class SampleThread extends Thread { public SampleThread() { super(); System.out.println("An instance of the " + SampleThread.class + " class was created!"); } @Override public void run() { try { /* Sleep for some seconds. */ TimeUnit.SECONDS.sleep(10); } catch(InterruptedException ex) { System.err.println("An InterruptedException was caught: " + ex.getMessage()); } } }
Monday, 13 February 2017
UnCheckedException : InterruptedExcept
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment