gpt4 book ai didi

java threading - 守护进程线程?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:42:26 27 4
gpt4 key购买 nike

被视为守护进程的线程会发生什么?

这对线程有什么影响?

线程上的“可以”和“不能”是什么?

最佳答案

daemon thread 是一个线程,当程序完成但线程仍在运行时,它不会阻止 JVM 退出。 守护线程是与守护线程运行在同一进程中的其他线程的服务提供者

例如垃圾收集。

您可以通过在 Thread 对象上调用 setDaemon(true) 显式地将用户线程创建的线程指定为守护线程。


供您引用,

Note that the setDaemon() method must be called before the thread's start() method is invoked.Once a thread has started executing (i.e., its start() method has been called) its daemon status cannot be changed. To determine if a thread is a daemon thread, use the accessor method isDaemon().

关于java threading - 守护进程线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6301031/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com