commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serge Knystautas <>
Subject Re: Question on Threadpool
Date Wed, 19 Nov 2003 15:29:46 GMT
David J. M. Karlsen wrote:
> Also I do not understand the DefaultThreadPool(int size) constructor:
> it calls startThread size times. startThread then does:
>   Thread thread = new Thread( this );
>         thread.start();
>         return thread;
> so the DefaultThreadPool replaces it's Thread object size times - what's 
> the point in that?
> what am I missing out on?

I think reading up on the Thread class and Runnable interface will help 
you understand what's going on here.  The phrase "replace it's Thread 
object" doesn't really make any sense.

The thread pool is creating a new Thread object that will call the 
DefaultThreadPool's run() method.  This run() method takes your worker 
tasks (that you handed the pool using invokeLater()), and runs that 
worker task.  This run() method loops until you call stop() on the 

If you want your stand-alone java app to stop, you'll need to call 
stop() on the pool.  Another alternate is to modify the 
DefaultThreadPool (or create another thread pool implementation) that 
creates these threads as daemon's, as the JVM will exit if only daemon 
threads are running.

Serge Knystautas
Lokitech >> software . strategy . design >>
p. 301.656.5501

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message