Thread pooling in AIO?

David M. Lloyd david.lloyd at redhat.com
Tue Dec 16 10:18:01 PST 2008


On 12/16/2008 11:48 AM, Nord, James wrote:
> The other thing is the default is awfull in our tests - as it seems to 
> create a new Thread in the pool for each AsyncDatagramChannel  (for 100 
> multicasts received there were 130+ java threads).

That's the way that fixed thread pools work.  The core size is equal to the 
pool size.  If ThreadPoolExecutor.execute() is called and the number of 
threads is below the core size, then a new thread is created rather than 
reusing an old one.  I think a fixed pool is probably the wrong choice for 
async I/O - it would make more sense to use a cached pool which can scale 
up on demand, with a sensible timeout for non-core threads.

One must also consider the task rejection policy - I don't think it would 
be a good thing for async I/O tasks to be rejected since the caller would 
have no idea what happened to the operation.  It would just "disappear".

As for the other questions, I can't answer. :-)

- DML



More information about the nio-discuss mailing list