-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
43 lines (33 loc) · 695 Bytes
/
Copy pathMain.java
File metadata and controls
43 lines (33 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package ThreadlivelockExample;
/**
* @author Virendra Singh
*
* The Class Main.
*/
public class Main {
/** The police. */
static Police police = new Police();
/** The criminal. */
static Criminal criminal = new Criminal();
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
new Thread(()->{
try {
police.giveRansom(criminal);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
new Thread(()->{
try {
criminal.releaseHostage(police);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
}