From owner-freebsd-java Sun Oct 7 7: 4:42 2001 Delivered-To: freebsd-java@freebsd.org Received: from azrael.xs4all.nl (azrael.xs4all.nl [213.84.220.111]) by hub.freebsd.org (Postfix) with ESMTP id 4CFC937B406 for ; Sun, 7 Oct 2001 07:04:37 -0700 (PDT) Received: (from remco@localhost) by azrael.xs4all.nl (8.11.6/8.11.6) id f97E4XE34842 for freebsd-java@FreeBSD.ORG; Sun, 7 Oct 2001 16:04:33 +0200 (CEST) (envelope-from remco) Date: Sun, 7 Oct 2001 16:04:33 +0200 From: "Remco van 't Veer" To: FreeBSD Java List Subject: jdk1.3.1p4_1: java.lang.Process blocks Thread.sleep() and Object.wait() Message-ID: <20011007160433.I66717@azrael.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Spook: Z-200 SART Mavricks 007 EAM PSAC Chobetsu ETA mutageen SBS AFSPC Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message