java 线程 获取当前线程
Thread th=Thread.currentThread(); System.out.println("Tread name:"+th.getName()); th.setName("我的测试线程:"); System.out.println("Tread name:"+th.getName()); for (int i = 0; i < 5; i++) { System.out.println(i); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }