sách gpt4 ăn đã đi

java - 可以将 main() 转换为守护线程

In lại 作者:搜寻专家 更新时间:2023-10-31 19:53:55 26 4
mua khóa gpt4 giày nike

据我所知,Java中的chủ yếu()默认是一个非守护线程,是否可以将其转换为守护线程?

câu trả lời hay nhất

如果只有守护线程在运行,那么 JVM 将关闭。如果主线程是守护线程,那么程序必须立即关闭才能运行。此外,您不能在线程启动后在其上设置守护进程属性,您不能在运行时将非守护线程更改为守护线程:

public final void setDaemon(boolean on)

Marks this thread as either a daemon thread or a user thread. The Java Virtual Machine exits when the only threads running are all daemon threads.

This method must be invoked before the thread is started.

关于java - 可以将 main() 转换为守护线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32726757/

26 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress