< prev index next >

test/javax/sound/sampled/DirectAudio/bug6400879.java

Print this page
rev 14569 : 8148915: Intermittent failures of bug6400879.java
Reviewed-by: amenkov

*** 24,37 **** /* * @test * @bug 6400879 7100140 * @summary Tests that Start/Stop sequence doesn't hang * @author Alexey Menkov ! * @run main bug6400879 ! * @key intermittent */ import javax.sound.sampled.*; public class bug6400879 extends Thread { public static void main(String args[]) throws Exception { --- 24,38 ---- /* * @test * @bug 6400879 7100140 * @summary Tests that Start/Stop sequence doesn't hang * @author Alexey Menkov ! * @run main/othervm bug6400879 */ + import java.util.concurrent.TimeUnit; + import javax.sound.sampled.*; public class bug6400879 extends Thread { public static void main(String args[]) throws Exception {
*** 48,67 **** public static void monitor(bug6400879 pThis) throws Exception { long prevLoop = -1; long prevTime = currentTimeMillis(); while (pThis.isAlive()) { if (pThis.loopCounter == prevLoop) { ! if (currentTimeMillis() - prevTime > BLOCK_TIMEOUT) { ! // block! ! log("Test FAILED."); ! throw new RuntimeException("Test FAILED: thread has been blocked!"); } } else { prevLoop = pThis.loopCounter; prevTime = currentTimeMillis(); } ! delay(500); // sleep for 0.5 sec } log("Test sucessfully passed."); } volatile long loopCounter = 0; --- 49,68 ---- public static void monitor(bug6400879 pThis) throws Exception { long prevLoop = -1; long prevTime = currentTimeMillis(); while (pThis.isAlive()) { if (pThis.loopCounter == prevLoop) { ! long delay = currentTimeMillis() - prevTime; ! if (delay > BLOCK_TIMEOUT) { ! // blocked? ! log("The test is slow, delay = " + delay); } } else { prevLoop = pThis.loopCounter; prevTime = currentTimeMillis(); } ! delay(1000); // sleep for 1 sec } log("Test sucessfully passed."); } volatile long loopCounter = 0;
*** 109,120 **** // helper routines static long startTime = currentTimeMillis(); static long currentTimeMillis() { ! //return System.nanoTime() / 1000000L; ! return System.currentTimeMillis(); } static void log(String s) { long time = currentTimeMillis() - startTime; long ms = time % 1000; time /= 1000; --- 110,120 ---- // helper routines static long startTime = currentTimeMillis(); static long currentTimeMillis() { ! return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); } static void log(String s) { long time = currentTimeMillis() - startTime; long ms = time % 1000; time /= 1000;
< prev index next >