How to shut down all Executors when quitting an application?

前端 未结 5 1325
离开以前
离开以前 2021-01-11 23:36

According to Brian Goetz\'s Java Concurrency in Practice JVM can\'t exit until all the (nondaemon) threads have terminated, so failing to shut down an Executor could pre

5条回答
  •  臣服心动
    2021-01-11 23:45

    Probably he meant to say JVM can't stop on its own until nondaemon threads are finished. Its like running a simple class from command like java SomeClass and after the execution of main method JVM stops.

    System.exit is a JVM termination command, even if daemon threads are running JVM will shutdown.

提交回复
热议问题