Date: Sun, 7 Oct 2001 16:04:33 +0200 From: "Remco van 't Veer" <rwvtveer@xs4all.nl> To: FreeBSD Java List <freebsd-java@FreeBSD.ORG> Subject: jdk1.3.1p4_1: java.lang.Process blocks Thread.sleep() and Object.wait() Message-ID: <20011007160433.I66717@azrael.xs4all.nl>
next in thread | raw e-mail | index | archive | help
Hi, The following code does not work as expected: public class Y { public static void main (String[] args) throws Exception { String[] pargs = { "sleep", "10" }; try { Runtime.getRuntime().exec(pargs); } catch (java.io.IOException ex) { } System.out.println("Sleep process is running.."); System.out.println("Now this thread will print a . every second"); for (int i = 0; i < 10; i++) { Thread.currentThread().sleep(1000); System.out.print("."); } System.out.println("."); } } The current thread will no wake up until the executed process has finished. The native 1.2.2 port and the linux jdk 1.3.1 both behave as expected. It takes them 10 seconds to execute this code. On the native 1.3.1 port this class takes 20 seconds to finish. Further investigation revealed something which may be of interest. Replacing: Thread.currentThread().sleep(1000); with: Object o = new Object(); synchronized (o) { o.wait(1000); } shows the same problem. BTW great port! It's starts up and runs very fast! Great work! TIA, Remco -- scilla: not so pure java media server <http://www.xs4all.nl/~rwvtveer/scilla/> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011007160433.I66717>