Can you dynamically resize a java.util.concurrent.ThreadPoolExecutor while it still has tasks waitin

Posted by Edward Shtern on Stack Overflow See other posts from Stack Overflow or by Edward Shtern
Published on 2010-05-07T21:45:49Z Indexed on 2010/05/07 21:48 UTC
Read the original article Hit count: 265

Filed under:
|

I'm working with a java.util.concurrent.ThreadPoolExecutor to process a number of items in parallel. Although the threading itself works fine, at times we've run into other resource constraints due to actions happening in the threads, which made us want to dial down the number of Threads in the pool. I'd like to know if there's a way to dial down the number of the threads while the threads area actually working. I know that you can call setMaximumPoolSize() and/or setCorePoolSize(), but these only resize the pool once threads become idle, but they don't become idle until there are no tasks waiting in the queue.

© Stack Overflow or respective owner

Related posts about java

Related posts about concurrency