I have read various blogs and javadoc regarding fixed thread pool and cached thread pool and when to use one over the other. But, they have various constructors and I am not very clear about all the parameters like core pool size etc. What is the difference between a fixed thread pool(nThreads) and a cached thread pool with core pool size as nThreads. I want to know about all the parameters of their constructors.
Asked
Active
Viewed 115 times
1
-
1Don't use the constructors, use the `Executors` utility class. For more information, read [the documentation](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html). – Boris the Spider Jan 01 '15 at 19:39
-
1I found [this SO question](http://stackoverflow.com/a/1800583/2071828) - it's a different question so not a dup, but the answer answers your question too. – Boris the Spider Jan 01 '15 at 20:28
1 Answers
1
The methods on Executors
are know as factory methods, rather than constructors.
A fixed thread pool has a fixed size, it is always the number of threads you tell it to be.
The cached pool, caches the threads it creates, it doesn't have a size, but rather it keeps track of the most threads it needed in the last minute, shutting down any threads which have not been used for a minute.

Peter Lawrey
- 525,659
- 79
- 751
- 1,130