Daemon threads scheduled on an ExecutorService; explain why this is bad form

后端 未结 3 1513
一整个雨季
一整个雨季 2021-02-01 06:18

I\'m comfortable with the idea of orderly shutdown on threads scheduled with an ExectuorService; that is to say, calling shutdown or shutdownNow<

3条回答
  •  鱼传尺愫
    2021-02-01 06:36

    I tend to have different pools for daemon and non-daemon threads. Daemon pools tend to do recurring clean up jobs, monitoring and background tasks which don't matter if one or two is not executed. Any task which is only meaningful while the application is still running is good to make a daemon thread task. e.g. GC threads are daemon threads.

提交回复
热议问题