From owner-freebsd-java Tue Nov 17 19:18:14 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA08509 for freebsd-java-outgoing; Tue, 17 Nov 1998 19:18:14 -0800 (PST) (envelope-from owner-freebsd-java@FreeBSD.ORG) Received: from teel.info-noire.com (03.XP11-2-1.Sherbrooke.InterLinx.qc.ca [207.253.144.23]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA08504 for ; Tue, 17 Nov 1998 19:18:09 -0800 (PST) (envelope-from alex@gel.usherb.ca) Received: from localhost (alex@localhost) by teel.info-noire.com (8.8.8/8.8.8) with SMTP id WAA11444; Tue, 17 Nov 1998 22:21:25 -0500 (EST) (envelope-from alex@teel.info-noire.com) Date: Tue, 17 Nov 1998 22:21:25 -0500 (EST) From: Alex Boisvert Reply-To: boia01@gel.usherb.ca To: Gunther Schadow cc: freebsd-java@FreeBSD.ORG Subject: Re: green threads vs. native threads ... In-Reply-To: <199811132244.RAA14641@aurora.rg.iupui.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Fri, 13 Nov 1998, Gunther Schadow wrote: [snip] > However, as it turned out, both threads are still waiting on each > other and, most of the time, the threads seem to execute sequentially > rather than parallel. [snip] > > w**********.*..*..*..*..*..*..*..*..*..w > > But look at the rest: ****************************** > *********************................................................. > ..w**************************...************************************** > .*.*.***************************************************************** > ***r.................................********************************* > r..................................................................... > ...........................................................w********** [snip] > ..........w********************************************............... > ............................. > > It seems like the two threads do no longer run in parallel. As you said, FreeBSD's JDK uses green threads. Green threads run at the user-level, not at the system-level. Which means that they don't "schedule" the same way as all the other (native) processes in your machine. With our JDK, you have to explicitly specify a 'timeslice' to make sure that your processor time is shared among each Java thread. To do this, you have to supply a command-line parameter to the VM, like this: java -ts100 YourMainClass This will give each thread 100 miliseconds of execution time before being preempted by another thread (context switch). Of course, threads can block and yield some of their allocated timeslice. Without this timeslicing concept enabled, your threads run as long as they don't block, which explains why you were seeing many dots "." and many asterisks "*" in a row. Give it a try... Alex. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message