
7.20 Errors and Exceptions in Java and Multithreaded Programming
51. Thread.sleep(1200);
52. }
53. }catch(InterruptedException e )
54. {System.out.println(“main thread interrupted”);}
55. System.out.println(“Exiting from main thread”);
56. }//end of main
57. }// end of ThreadRunnableDemo
Output: Creating FirstThread2
Creating FirstThread2Thread[FirstThread2,5,main]
thread1 :0 :
Creating SecondThread2
Creating SecondThread2Thread[FirstThread2,5,main]
threadMain :0 :
thread1 Details
Name :FirstThread2
Priority :5
thread2 :0 : thread1 :1 : thread2 :1 : thread1 :2 :
threadMain :1 : thread2 :2 : thread1 :3 : thread2 :3 :
Exiting from thread1 threadMain :2 : ...