Executor and Daemon in Java

前端 未结 3 2050
北海茫月
北海茫月 2020-12-09 12:27

I have a MyThread object which I instantiate when my app is loaded through the server, I mark it as a Daemon thread and then call start() on it. The thread is m

3条回答
  •  半阙折子戏
    2020-12-09 12:39

    If you're using a scheduled executor, you can provide a ThreadFactory. This is used to create new Threads, and you can modify these (e.g. make them daemon) as you require.

    EDIT: To answer your update, your ThreadFactory just needs to implement newThread(Runnable r) since your WebRunnable is a Runnable. So no real extra work.

提交回复
热议问题