提交 1f779117 编写于 作者: A alanb

7114125: TEST_BUG: java/util/Timer/KillThread.java should use volatile cross...

7114125: TEST_BUG: java/util/Timer/KillThread.java should use volatile cross thread variable declaration
Reviewed-by: dholmes, alanb
Contributed-by: gary.adams@oracle.com
上级 b9a9e8f7
......@@ -31,14 +31,14 @@
import java.util.*;
public class KillThread {
static volatile Thread tdThread;
public static void main (String[] args) throws Exception {
final Thread[] tdThread = new Thread[1];
Timer t = new Timer();
// Start a mean event that kills the timer thread
t.schedule(new TimerTask() {
public void run() {
tdThread[0] = Thread.currentThread();
tdThread = Thread.currentThread();
throw new ThreadDeath();
}
}, 0);
......@@ -47,10 +47,10 @@ public class KillThread {
try {
do {
Thread.sleep(100);
} while(tdThread[0] == null);
} while(tdThread == null);
} catch(InterruptedException e) {
}
tdThread[0].join();
tdThread.join();
// Try to start another event
try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册