specifying ThreadPoolExecutor problem
        Posted  
        
            by Sarmun
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sarmun
        
        
        
        Published on 2009-09-16T22:45:12Z
        Indexed on 
            2010/03/31
            16:03 UTC
        
        
        Read the original article
        Hit count: 201
        
Is there any way to create Executor that will have always at least 5 threads, and maximum of 20 threads, and unbounded queue for tasks (meaning no task is rejected)
I tried new ThreadPoolExecutor(5, 20, 60L, TimeUnit.SECONDS, queue)
with all possibilities that I thought of for queue:
new LinkedBlockingQueue() // never runs more than 5 threads
new LinkedBlockingQueue(1000000) // runs more than 5 threads, only when there is more than 1000000 tasks waiting
new ArrayBlockingQueue(1000000) // runs more than 5 threads, only when there is more than 1000000 tasks waiting
new SynchronousQueue() // no tasks can wait, after 20, they are rejected
and none worked as wanted.
© Stack Overflow or respective owner