public class A{//构造函数 public A(){ Thread t = new Thread(); t.start(); //在构造函数启动线程}//析构函数~A(){ t.close();//在析构函数中关闭线程}}