11package  Deadlock_11 ;
22
33/** 
4-  * Deadlock can occur in a situation when a thread is waiting for an object 
5-  * lock, that is acquired by another thread and second thread is waiting for an 
4+  * <a href="https://wikipedia.org/wiki/Deadlock">Deadlock</a> 
5+  * can occur in a situation when a thread is waiting for an object's lock, 
6+  * that is acquired by another thread and the second thread is waiting for an 
67 * object lock that is acquired by first thread. Since, both threads are waiting 
78 * for each other to release the lock, the condition is called deadlock. If you 
89 * make sure that all locks are always taken in the same order by any thread, 
910 * deadlocks cannot occur. 
10-  * 
11-  * Codes with minor comments are from http://www.caveofprogramming.com/youtube/ 
11+  * <br><br> 
12+  * Codes with minor comments are from 
13+  * <a href="http://www.caveofprogramming.com/youtube/"> 
14+  * <em>http://www.caveofprogramming.com/youtube/</em> 
15+  * </a> 
16+  * <br> 
1217 * also freely available at 
13-  * https://www.udemy.com/java-multithreading/?couponCode=FREE 
18+  * <a href="https://www.udemy.com/java-multithreading/?couponCode=FREE"> 
19+  *     <em>https://www.udemy.com/java-multithreading/?couponCode=FREE</em> 
20+  * </a> 
1421 * 
1522 * @author Z.B. Celik <[email protected] > 1623 */ 
@@ -22,21 +29,15 @@ public static void main(String[] args) throws Exception {
2229            public  void  run () {
2330                try  {
2431                    runner .firstThread ();
25-                 } catch  (InterruptedException  e ) {
26-                     // TODO Auto-generated catch block 
27-                     e .printStackTrace ();
28-                 }
32+                 } catch  (InterruptedException  ignored ) {}
2933            }
3034        });
3135
3236        Thread  t2  = new  Thread (new  Runnable () {
3337            public  void  run () {
3438                try  {
3539                    runner .secondThread ();
36-                 } catch  (InterruptedException  e ) {
37-                     // TODO Auto-generated catch block 
38-                     e .printStackTrace ();
39-                 }
40+                 } catch  (InterruptedException  ignored ) {}
4041            }
4142        });
4243
@@ -46,5 +47,4 @@ public void run() {
4647        t2 .join ();
4748        runner .finished ();
4849    }
49- 
5050}
0 commit comments