Received: from PACIFIC-CARRIER-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA04120; Fri, 15 Mar 96 22:32:47 EST
Received: from liquor.cabi.net by MIT.EDU with SMTP
	id AB13380; Fri, 15 Mar 96 22:31:58 EST
Received: by liquor.cabi.net (8.7.3/8.7.3) id WAA07147; Fri, 15 Mar 1996 22:33:54 -0500
Resent-Date: Fri, 15 Mar 1996 22:33:54 -0500
Date: Sat, 16 Mar 1996 04:29:35 +0100 (MET)
From: Davide Rossi <rossi@cs.unibo.it>
X-Sender: rossi@luniga
To: Lincoln Stein <lstein@kaa.crbm.cnrs-mop.fr>
Cc: java-linux@java.blackdown.org, mieg@kaa.crbm.cnrs-mop.fr
Subject: Re: Thread.yield() doesn't
In-Reply-To: <199603151437.PAA06152@pico.crbm.cnrs-mop.fr>
Message-Id: <Pine.SUN.3.91.960316042318.20020C-100000@luniga>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Resent-Message-Id: <"kwqFz1.0.Jk1.XPZIn"@liquor>
Resent-From: java-linux@java.blackdown.org
X-Mailing-List: <java-linux@java.blackdown.org> archive/latest/1412
X-Loop: java-linux@java.blackdown.org
Precedence: list
Resent-Sender: java-linux-request@java.blackdown.org



On Fri, 15 Mar 1996, Lincoln Stein wrote:

> Hi all,
> 
> Here's another question that's more Java-oriented than Linux oriented,
> but you've been so helpful with my previous problems that I thought
> I'd try again.
> 
> My program opens up connections to a database via a TCP/IP connection,
> retrieves some information and displays it.  The database is a large
> object-oriented db of genomic information and contains both large
> objects, such as DNA sequences, and small objects such as author's
> e-mail addresses.
> 
> Since the database itself is multi-threaded, I take advantage of that
> fact by spawning a new thread every time a database access is needed,
> opening up a new database connection (or reusing an old inactive one),
> and downloading and parsing the information as a background task.
> 
> The problem is that time-slicing doesn't seem to be implemented on the
> Linux platform.  The first thread grabs the CPU and holds onto it
> until its inner read-and-parse loop is done.  Very annoying.
> 
> So I RTFMed and found the Thread.yield() call.  I threw that into the
> inner loop and no dice: thread swapping is still not working.
> 
> So I changed the Thread.yield() call to Thread.sleep(10), and that
> works just fine.  The threads download and parse in parallel.
> Unfortunately there's now a 10 msec wait in my inner loop, so
> everything crawls, but I think this test excludes the possibility that
> my synchronized methods are holding locks and not relinquishing them.
> 
> I've played with setting priorities, but this doesn't seem to improve
> things.  Does anyone have an idea of what might be going wrong?  Are
> there subtleties to the yield() method that I don't understand?
> 
I did wrote a similar server. Each time it receives a new connection it runs
a new thread to handle requests. I don't have your problem 'cause I simply
have a wait() at the end of the servicing loop but I remember I used yield()
and worked fine with my beta1 port... maybe something is broken with test4?

Ciao,
	Davide.

