runable怎么获取线程名字getname和setname

    public static void main(String[] args) throws InterruptedException {

        Runnable same=new CheckSame();
        Thread t=new Thread(same,"ssss");
        t.getName();
        t.start();
    }

    @Override
    public void run() {
       getName();//Thread
       Thread.currentThread().getName();//runnable
    }

猜你喜欢

转载自blog.csdn.net/sunyufeng22/article/details/121022911