多线程Thread(获取线程名字)

package com.day18.Thread;

public class ThreadFour {

    public static void main(String[] args) {
        new Thread("Lakers") {
            public void run() {
                System.out.println(this.getName()+"  Kobe");
            }
        }.start();
        
        new Thread("Celtics") {
            public void run() {
                System.out.println(this.getName()+"  KG");
            }
        }.start();
    }

}

猜你喜欢

转载自www.cnblogs.com/zhujialei123/p/9275843.html