I expect the answer to my question warmly.

解决方案 »

  1.   

    Daemon线程,如果有线程使用Daemon的话
    那么它就不退出,如果只有Daemon线程
    那么程序就退出了,你可以测试一下。
    一个程序开始时线程,不是Daemon的
    通过按钮或者,其他方法把它setDaemon(true)
    你就看到Daemon的效果了
      

  2.   

    从书上说,“Daemon”线程主要依赖于非“Daemon”线程
    setDaemon(true) 的作用是将此线程设置为后台进程后面的问题你一定是搞错了
    你可能是
    那为何"屏蔽掉"【setDaemon(true);】而"不屏蔽掉"main[]方法中【BufferedReader stdin =】此句以后的代码(含此句)也会出现出现无法退出程序?
    因为程序在等待你输入, 你给他一个回车肯定退出了
      

  3.   

    1、new Daemon()若不设为deamon线程因为有
    while(true) yield();
         ^^^^^^
    会永远徘徊于此处,即使主线程执行完毕。
    2、注释掉stdin.readLine();(阻塞性方法会在那傻等回车)后程序正常退出,已上机测试。
      

  4.   

    Could somebody tell me the difference between Daemon thread and no-Daemon thread?
    I feel come confusion, Thanks!