一个关于线程的问题:线程停止以后,就会被回收吗?
各位好
public class Testing{ private static TestThread tester; class TestThread extends Thread { private int index = 0; private boolean running = true; @Override public void run() { while (running) { System.out.println("" + ++index); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } } public void setRunning(boolean running) { this.running = running; } } public static void main(String[] args) { // 开启线程 tester = new TestThread(); tester.start(); // 消毁线程 tester.setRunning(false); tester = null;