Thread Groups 7.29
18. System.out.println(“Inside main Method”);
19. DaemonThreadDemo3 t = new DaemonThreadDemo3();
20. t.setDaemon(true);
21. t.start();
22. try {
23. Thread.sleep(6000);//to allow back ground jobs
24. } catch (InterruptedException x) {
25. }
26. System.out.println(“Exiting main method”);
27. }
28. }
Output
Inside main Method
in run method
In side run method. The current Thread is Thread[Thread-0,5,main]
back ground back ground back ground back ground back ground
back ground back ground back ground back ground back ground
back ground back ground
Exiting main method
7.18 Deadlock in Multithreaded Programming
Dead lock will occur if there are two synchronized objects and two threads working inde-
pendently on these synchronized objects ...