On May 3, 2001 at 12:46, "Michael Gerdau" wrote:
> >I'd rather have different ThreadPool instances for different 'names'.
> >
> > importantThreadPool.dispatch( aRunnable );
> > backgroundThreadPool.dispatch( anotherRunnable );
>
> I doubt that it would be a good idea to try to "outwitt" the OS's
> taskmanager w/r to clever allocation of processtime.
>
> The only exception might be for realtime-critical applications but
> even then I doubt it would be clever to implement it on such a high
> level.
>
> I'd rather allow an optional "priority" parameter but even this one
> should only be very rough (as in HIGH, NORMAL, LOW, IDLE).
An option is to provide access to the ThreadGroup object to allow
properties to be defined for all threads in the pool. I did this for
a ThreadPool class I wrote. The ThreadGroup can be retrieved before
starting the pool inorder to set any properties desired (like priority).
A more general approach, that was already mentioned, is to allow one to
specify a custom ThreadFactory so if one needs to set properties of the
threads used, they can create a ThreadFactory implementation to do it.
--ewh