changeset 6126:c1917562bcd5

6818464: TEST_BUG: java/util/Timer/KillThread.java failing intermittently Reviewed-by: dholmes, alanb, forax Contributed-by: gary.adams@oracle.com
author alanb
date Sat, 19 Nov 2011 19:55:19 +0000
parents 4f5897ab2603
children 35961dabc4ec
files test/java/util/Timer/KillThread.java
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/Timer/KillThread.java	Thu Apr 19 13:26:06 2012 -0700
+++ b/test/java/util/Timer/KillThread.java	Sat Nov 19 19:55:19 2011 +0000
@@ -32,20 +32,25 @@
 
 public class KillThread {
     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();
                 throw new ThreadDeath();
             }
         }, 0);
 
         // Wait for mean event to do the deed and thread to die.
         try {
-            Thread.sleep(100);
+            do {
+                Thread.sleep(100);
+            } while(tdThread[0] == null);
         } catch(InterruptedException e) {
         }
+        tdThread[0].join();
 
         // Try to start another event
         try {