获取当前线程名称

package com.lxxu.testthread;

class MyThread6 implements Runnable{//线程的主体类
	
	@Override
		public void run(){//线程的主体方法
			System.out.println(Thread.currentThread().getName());
		}
}

public class ThreadDemo6{
	public static void main(String[] args){
		MyThread6 mt = new MyThread6();
		new Thread(mt,"线程A").start();
		mt.run();	//	run方法也是一个线程
	}
}

猜你喜欢

转载自blog.csdn.net/qq_42740745/article/details/84642672
今日推荐