以下实例演示了如何通过继承 Thread 类并使用 currentThread.getName() 方法来监测线程的状态:
Main.java 文件
以上代码运行输出结果为:
…… alive alive MyThread #1 terminating. alive ……