相关疑难解决方法(0)

是否收集了Java Thread Garbage

这个问题发布在某个网站上.我没有在那里找到正确的答案,所以我再次在这里发布.

public class TestThread {
    public static void main(String[] s) {
        // anonymous class extends Thread
        Thread t = new Thread() {
            public void run() {
                // infinite loop
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                    // as long as this line printed out, you know it is alive.
                    System.out.println("thread is running...");
                }
            }
        };
        t.start(); // Line A
        t = null; // Line B
        // no more references for Thread t
        // another infinite …
Run Code Online (Sandbox Code Playgroud)

java multithreading garbage-collection

84
推荐指数
4
解决办法
3万
查看次数

标签 统计

garbage-collection ×1

java ×1

multithreading ×1