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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -