追着幸福跑|两分钟浅述DaemonThread守护线程(附英文)

大家都知道 , 在Java中有两种线程:User Thread(用户线程)和DaemonThread(守护线程) 。 那它们有何区别呢?
追着幸福跑|两分钟浅述DaemonThread守护线程(附英文)守护线程
What is Daemon thread?Daemon thread is a low priority thread that runs in background to perform tasks such as garbage collection.
守护线程是一个低优先级的线程 , 它在后台运行 , 执行像垃圾收集等任务 。
Properties:
1.They can not prevent the JVM from exiting when all the user threads finish their execution.
它们不能阻止JVM在所有用户线程执行完毕后退出 。
2.JVM terminates itself when all user threads finish their execution.
当所有用户线程执行完毕后 , JVM自行终止 。
3.If JVM finds running daemon thread, it terminates the thread and after that shutdown itself. JVM does not care whether Daemon thread is running or not.
如果JVM发现正在运行的守护进程线程 , 它就会终止该线程 , 然后关闭自己 。 JVM并不关心Daemon线程是否在运行 。
4.It is an utmost low priority thread.
【追着幸福跑|两分钟浅述DaemonThread守护线程(附英文)】守护线程是一个最低级别的线程 。


    推荐阅读