1.實例化一個線程對象
1 Thread t = new Thread(); 2 t.setName("甲");
2.實例化一個線程對象的同時,通過構造方法對線程進行命名
1 Thread(Runnable r, String name) 2 Thread t = new Thread(() -> {}, "甲");
3.使用自定義的線程類,在實例化線程對象的同時,進行名稱的賦值
1 MyThread t = new MyThread("甲"); 2 3 class MyThread extends Thread{ 4 5 public MutliTread(String name) { 6 this.setName(name); 7 //super(name) 8 } 9 public void run() {...} 10 }