java daemon threads

前端 未结 4 1633
春和景丽
春和景丽 2021-01-22 06:45

Hi all, will daemon thread stop working when the enclosing it thread will finish? Or daemon thread will stop when the \"main\" thread will finish?

I tested this example

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-22 07:05

    Since the main thread ends as soon as the simple thread is started, the simple thread is the last application thread to finish, so the daemon thread ends when this thread ends.

    The fact that the simple thread is the one that started the daemon thread has nothing to do with that.

提交回复
热议问题