}// Interrupt all methods in the same thread group as the main threadThread.currentThread().getThreadGroup().interrupt(); }//一个启动以后进入等待,直到被interrupt的线程staticclassMyThreadextendsThread{publicvoidrun(){synchronized("A") { System.out.println(getName() +" about to wait.");try{...
interrupt()方法的作用是通知线程应该中断了,具体到底中断还是继续运行,由被通知的线程处理。 publicclassThreadGroupExampleInterrupt{publicstaticvoidmain(String[]args){// Start two threadsMyThreadmt=newMyThread();mt.setName("A");mt.start();mt=newMyThread();mt.setName("B");mt.start();// Wait ...