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.
So - the question is, does Java Thread semantics allow the sort of
behavior I'd like at all. If so, do either of the Linux threading
options actually support it. If not (bummer), I guess I must introduce
explicit end state detection (My problem is, of course, rather more
complex than the example given here, but the issues are similar).
Thanks,
- Michael Thome
[EMAIL PROTECTED]