--- old/test/java/lang/Thread/GenerifyStackTraces.java 2013-05-15 18:58:06.825941231 +0800 +++ new/test/java/lang/Thread/GenerifyStackTraces.java 2013-05-15 18:58:06.192851302 +0800 @@ -23,7 +23,7 @@ /* * @test - * @bug 4919105 + * @bug 4919105 8004177 * @summary Generified basic unit test of Thread.getAllStackTraces() * @author Mandy Chung */ @@ -33,7 +33,6 @@ public class GenerifyStackTraces { private static Object go = new Object(); - private static Object dumpObj = new Object(); private static String[] methodNames = {"run", "A", "B", "C", "Done"}; private static int DONE_DEPTH = 5; private static boolean testFailed = false; @@ -48,19 +47,26 @@ one = new ThreadOne(); one.start(); - Thread dt = new DumpThread(); - dt.setDaemon(true); + DumpThread dt = new DumpThread(); dt.start(); + try { + one.join(); + }finally { + dt.shutdown(); + } + if (testFailed) { throw new RuntimeException("Test Failed."); } } static class DumpThread extends Thread { + private volatile boolean finished = false; + public void run() { int depth = 2; - while (true) { + while (!finished) { // At each iterator, wait until ThreadOne blocks // to wait for thread dump. // Then dump stack trace and notify ThreadOne to continue. @@ -75,6 +81,11 @@ } } } + + public void shutdown() throws InterruptedException { + finished = true; + this.join(); + } } static class ThreadOne extends Thread {