非守护线程的所有线程都已停止运行,无论是通过从对run方法的调用中返回,还是通过抛出一个传播到run方法之外的异常。
All threads that are not daemon threads have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method.
请注意 Timer 却创建了一个非守护线程在后台启动任务,因此在清单 10 中我需要调用 System.exit() 来取消任务。
Note that Timer creates a non-daemon thread to fire the tasks in the background, however, so in Listing 10 I have to kill the VM via a call to System.exit().
应用推荐