On Fri, 13 Nov 1998 11:20:36 -0500 (EST), Michael Thome wrote:

>Now that we have the option of native threads, I'd like to start using 
>thread resource pools.  But, the Java semantics and/or the
>implementation appears to make it problematic with regard to
>applications without a known exit condition... here's my problem:
>
>I want my application to exit when all computation is done - for
>purposes of discussion, consider a fractal image generator which uses
>threads to farm out work.
>
>Let's say I create a pool of 10 threads to do the work:
>
>If they are normal threads, the threads in the pool need to be in a
>wait state (e.g. when idle) - but waiting (or interrupted) is still
>active, so the vm will not exit even when all the threads are idle.
>
>If they are daemon threads, the VM will likely exit too early, because 
>running daemons alone aren't enough to keep the VM alive.
>
>I want to write my thread pool as a generic class, so I want to avoid
>introducing an otherwise external sync point (work all done) to
>actually kill the threads in the pool at job completion time.

I have a generic thread pool class that works for me.  It is not
complete for public use (yet) but it does the job.  It knows when
it has no threads in use.  It also dynamically expands as peak
loading increases.

The trick is that you need a "front-end" class to the thread class
and then a class that manages the set of threads.


Michael Sinz -- Director of Research & Development, NextBus Inc.
mailto:[EMAIL PROTECTED] --------- http://www.nextbus.com
My place on the web ---> http://www.users.fast.net/~michael_sinz

Reply via email to