-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathStopSleep.java
More file actions
34 lines (27 loc) · 737 Bytes
/
StopSleep.java
File metadata and controls
34 lines (27 loc) · 737 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
package concurrent;
/**
* @version 2017/12/19.
*/
public class StopSleep {
public static class Task1 implements Runnable {
@Override
public void run() {
while (true) {
try {
System.out.println("doing....");
Thread.sleep(10000);
System.out.println("done....");
} catch (InterruptedException e) {
System.out.println("interrupted");
break;
} catch (Exception e) {
}
}
}
}
public static void main(String[] args) {
Thread t = new Thread(new Task1());
t.start();
t.interrupt();
}
}