1.6getId()方法

getId()方法的作用是获取线程的唯一标识。

测试执行类:

public class Main {
    public static void main(String[] args) {
        Thread t = Thread.currentThread();
        System.out.println(t.getName() + "---" + t.getId());
    }
}

结果:

原文地址:https://www.cnblogs.com/lilinzhiyu/p/7941824.html