Discussion:
question on ThreadPoolExecutor
Ted Yu ted_yu-/E1597aS9LQAvxtiuMwx3w@public.gmane.org [seajug]
2014-07-25 15:30:37 UTC
Permalink
Hi,
The JDK ThreadPoolExecutor creates all the threads in the pool. As a consequence, we create (by default) 256 threads even if we just need a few.

Does anyone know of an ExecutorService which creates threads only if we have something in the queue ?

Thanks
Joe Bowbeer joe.bowbeer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org [seajug]
2014-07-25 16:05:54 UTC
Permalink
Check out the factory methods in the Executors tool class.

I think you are interested in the difference between newFixedThreadPool and
newCachedThreadPool.
Hi,
The JDK ThreadPoolExecutor creates all the threads in the pool. As a
consequence, we create (by default) 256 threads even if we just need a few.
Does anyone know of an ExecutorService which creates threads only if we
have something in the queue ?
Thanks
Loading...