File tree 1 file changed +26
-3
lines changed
1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,23 @@ public static void main(String[] args) {
12
12
@ Override
13
13
public void run () {
14
14
try {
15
- for (; ; ) {}
15
+ while (!Thread .currentThread ().isInterrupted ()) {
16
+ for (; ; ) {
17
+ System .out .println (
18
+ "--> Thread name : "
19
+ + Thread .currentThread ().getName ()
20
+ + ", id = "
21
+ + Thread .currentThread ().getId ());
22
+ System .out .println ("i = " );
23
+ }
24
+ }
25
+
26
+ // for (; ; ) {
27
+ // System.out.println("i = ");
28
+ // }
29
+ // for (int i = 0; i < 10; i++) {
30
+ // System.out.println("i = " + i);
31
+ // }
16
32
17
33
} finally {
18
34
System .out .println ("FINALLY" );
@@ -26,12 +42,19 @@ public void run() {
26
42
try {
27
43
future .get (3 , TimeUnit .SECONDS );
28
44
} catch (TimeoutException e ) {
45
+
46
+ System .out .println (">>> (before) future.cancel" );
29
47
boolean c = future .cancel (true );
48
+ System .out .println (">>> (after) future.cancel" );
49
+
30
50
System .out .println ("Timeout " + c );
31
51
} catch (InterruptedException | ExecutionException e ) {
32
52
System .out .println ("interrupted" );
53
+ } finally {
54
+ System .out .println ("executor.shutdown" );
55
+ executor .shutdown ();
56
+ System .out .println ("END" );
33
57
}
34
- System .out .println ("END" );
35
58
}
36
-
59
+
37
60
}
You can’t perform that action at this time.
0 commit comments