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

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -