From 51c31e33a6a512dc706764dd1cc5794833db4a7d Mon Sep 17 00:00:00 2001 From: robm Date: Mon, 15 Oct 2012 03:26:11 +0100 Subject: [PATCH] 8000817: Reinstate accidentally removed sleep() from ProcessBuilder/Basic.java Reviewed-by: alanb, martin --- test/java/lang/ProcessBuilder/Basic.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/java/lang/ProcessBuilder/Basic.java b/test/java/lang/ProcessBuilder/Basic.java index feff054c6..8ad7bd937 100644 --- a/test/java/lang/ProcessBuilder/Basic.java +++ b/test/java/lang/ProcessBuilder/Basic.java @@ -41,6 +41,7 @@ import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.security.*; +import sun.misc.Unsafe; import java.util.regex.Pattern; import java.util.regex.Matcher; import static java.lang.System.getenv; @@ -1960,6 +1961,7 @@ public class Basic { thread.start(); latch.await(); + Thread.sleep(10); String os = System.getProperty("os.name"); if (os.equalsIgnoreCase("Solaris") || @@ -1984,6 +1986,15 @@ public class Basic { while (useCountField.getInt(deferred) <= 0) { Thread.yield(); } + } else if (s instanceof BufferedInputStream) { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + Unsafe unsafe = (Unsafe)f.get(null); + + while (unsafe.tryMonitorEnter(s)) { + unsafe.monitorExit(s); + Thread.sleep(1); + } } p.destroy(); thread.join(); -- GitLab