On Mon, Apr 23, 2001 at 11:56:46PM -0500, Owen Williams wrote:
> > > 
> > > well I noticed when I did my development that the wait() commands sucked
> > > up oodles of time by calling while(!done){wait();}.  The JVM decided
> > > that spending 100% cpu time doing that call was the best way to do
> > > things.  by adding a sleep command the CPU usage drops, and there is no
> > > noticeable decrease in performance.
> > > 
> > > while(!done){wait();sleep(1000);}
> > 
> > Where in the code does this go?
> > 
> > -- 
> 
> this was in dumpBuckets and fillBuckets of the Client classes.
> 
> specifically:
> 
> try {
>      dl.waitEvent();
> } catch (InterruptedException e) {}
> 
> the listener just does while(!isComplete) wait(); which sucks cycles

No it doesn't.  It wait()'s until it gets notified by another thread,
checks if isComplete has been set, and if not, it waits to be notified
again.  That's not a busy wait.

-- 

# tavin cole
#
# "The process of scientific discovery is, in effect,
#  a continual flight from wonder."
#                                   - Albert Einstein


_______________________________________________
Devl mailing list
[EMAIL PROTECTED]
http://lists.freenetproject.org/mailman/listinfo/devl

Reply via email to