-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathStopThread.java
More file actions
33 lines (27 loc) · 797 Bytes
/
StopThread.java
File metadata and controls
33 lines (27 loc) · 797 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
/*
* @(#)StopThread.java $version 2011. 11. 16.
*
* Copyright 2007 NHN Corp. All rights Reserved.
* NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package ej2.item66.broken;
import java.util.concurrent.TimeUnit;
/**
* @author benelog
*/
public class StopThread {
private static Boolean stopRequested = Boolean.FALSE;
public static void main(String[] args)
throws InterruptedException {
Thread backgroundThread = new Thread(new Runnable() {
public void run() {
int i = 0;
while (stopRequested.equals(Boolean.FALSE))
i++;
}
});
backgroundThread.start();
TimeUnit.SECONDS.sleep(1);
stopRequested = Boolean.TRUE;
}
}