Thread contention

mrochon mattrochon at gmail.com
Thu Jun 17 09:10:59 EDT 2010


Hi Trustin, thanks for your response,

The problem I am seeing is as such:

I construct my worker thread pool with the following code:

[code]
     new ThreadPoolExecutor(MIN_POOL_SIZE, poolSize, idleTimeout,
TimeUnit.SECONDS, (BlockingQueue)(new
ArrayBlockingQueue<Runnable>(maxQueuedTasks)));
[/code]

With:
MIN_POOL_SIZE=1
poolSize=50
idleTimeout=60
maxQueuedTasks=50000


The problem is, as soon as my number of connections reaches MIN_POOL_SIZE
connections will block until the queue fills up, before creating new
threads.

If I close the (1=MIN_POOL_SIZE) working connection, the next one starts
working, as if the thread was bound to the connection.

With a synchronous queue, the threads are active but able to serve multiple
connections. I'm not sure what I am doing wrong.

I understand that the executor will prefer to queue a task rather than
create a new thread, and maxQueuedTasks is just an initial parameter to be
tuned. But I would expect the active threads to be executing the queued
tasks instead of blocking until the connection closes.
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Thread-contention-tp5186733p5190873.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list