getId()方法的作用是获取线程的唯一标识。 测试执行类: public class Main { public static void main(String[] args) { Thread t = Thread.currentThread(); System.out.println(t.getName() + "---" + t.getId()); } } 结果: