stujike
 1 package com.xyzx.thread;
 2 
 3 public class ThreadDemo extends Thread{
 4     
 5     public void run(){
 6         Thread thread = Thread.currentThread();
 7         for (int i = 0; i < 10; i++) {
 8             System.out.println("正在运行"+thread.getName() + ",运行次数:" + i);
 9         }
10     }
11 
12     public static void main(String[] args) {
13         ThreadDemo threadDemo = new ThreadDemo();
14         threadDemo.start();
15         for (int i = 0; i < 10; i++) {
16             System.out.println("正在运行的线程:" + Thread.currentThread().getName() + ", 运行次数:" + i);
17         }
18     }
19 }

结果:

 

分类:

技术点:

相关文章:

  • 2022-02-07
  • 2022-02-07
  • 2022-02-07
  • 2021-08-25
  • 2022-12-23
  • 2021-09-12
  • 2021-11-23
猜你喜欢
  • 2021-09-24
  • 2022-12-23
  • 2021-11-23
  • 2021-12-08
  • 2021-12-08
  • 2021-11-28
相关资源
相似解决方案