对Thread.currentThread方法,isAlive()方法的一些思考

Thread.currentThread方法

currentThread方法可返回代码段正在被哪个线程调用。例如:

public class Run {
   
    public static void main(String[] args) {
   
        System.out.println(Thread.currentThread().getName());
    }
}
控制台打印:main

然而,当该方法用在线程中时就有点迷惑人了:


public class CountOperate extends Thread{
   
    public CountOperate() {
   
        System.out.println("CountOperate --- start");
        System.out.println("Thread.currentThread.getName()=" + Thread.currentThread().getName());
        System.out.println("this.getname()=" + this.getName());
        System.out.println("CountOperate --- end");
    }

    @Override
    public 

你可能感兴趣的:(java多线程,java,java-ee)