Reputation: 11
I have a created a ThreadPoolExecuter with corePool size = 10 and Max Pool Size = 50 and work Queue = 100 and on local machine everything is working as expected but on dev server (linux machine) the thread pool is active for few hours and then gets shutdown automatically.
So After that all the new tasks are getting rejected.
The tasks that we are assigning to this thread pool has a timeout of 25 seconds.
And we have multiple ThreadPools as well but they get shutdown when we shutdown the server.
private static ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(100);
ThreadFactory threadFactory = getNamedTreadFactory(false, "Thread-01");
xecutorService es = new ThreadPoolExecutor(10, 50, 3, TimeUnit.SECONDS, workQueue, threadFactory, handler);
Upvotes: 1
Views: 566
Reputation: 11
The Reason behind this issue is that we had the ServletContextListner implemention that listen context activity. So when on DEV server code get pushed then application was getting hot-deployed and application context was getting recreated , this time it was shutting down the pool.
public class ApplicationContextListner implements ServletContextListener{
@Override
public void contextDestroyed(ServletContextEvent arg0) {
//Here the pool shutdown code was present - so we removed it
}}
After removing pool shutdown call from destroy method.It worked.
Issue Resolved.
Upvotes: 0