anpajin

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();
}
}

 

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-12-15
  • 2021-12-05
  • 2021-12-05
  • 2021-12-15
  • 2021-08-07
  • 2021-12-22
  • 2021-11-18
猜你喜欢
  • 2021-11-19
  • 2021-12-11
  • 2021-09-14
  • 1970-01-01
  • 2021-07-02
  • 2021-12-23
  • 2021-11-23
相关资源
相似解决方案