In continuation to a question posted by me, I'm trying to use ThreadPoolExecutor in my codebase. Even after repeated attempts to comprehend from Java API doc, I failed to understand clearly the functionality/purpose behind keepAliveTime parameter to be passed in the constructor. Hope somebody can explain me with some good working example.
Excerpts from Java doc:
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue)
keepAliveTime - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
ThreadPoolExecutorby writing your own code implementing that API - you're just creating aThreadPoolExecutorand you want to know how it will behave, right? - Jon SkeetThreadPoolExecutor. It's really helpful if you can use terminology appropriately - particularly on Stack Overflow. - Jon Skeet