java - ExecutorService is not shutting down -
i have following code
executorservice es = executors.newsinglethreadexecutor(); es.submit(new runnable() { @override public void run() { while(true); } }); es.shutdownnow();
the problem executorservice doesn't shutdown after call shutdownnow. documentation says attempts stop actively executing tasks.
so why es failing shutdown?
i did , worked:
executorservice es = executors.newsinglethreadexecutor(); es.submit(new runnable() { @override public void run() { while(!thread.currentthread().isinterrupted()); } }); es.shutdownnow();
the reason shutdownnow
doesn't terminate thread. interrupts running threads.
Comments
Post a Comment