package edu.xcdq.Demo01;
/**
* @author yuhuicun
* @date 2021/5/19 7:58
*/
public class Demo01 extends Thread {
public Demo01(){
}
public Demo01(String name){
super(name);
}
@Override
public void run(){
System.out.println("这是一个新线程");
System.out.println("名字:"+Thread.currentThread().getName());
}
}
package edu.xcdq.Demo01;
import edu.xcdq.Demo01.Demo01;
/**
* @author yuhuicun
* @date 2021/5/19 8:34
*/
public class TestDemo01 {
public static void main(String[] args) {
/*Demo01 demo01 = new Demo01("线程1");
demo01.start();
}*/
Demo01 demo01 = new Demo01("1");
Demo01 demo02 = new Demo01("2");
Demo01 demo03 = new Demo01("3");
Demo01 demo04 = new Demo01("4");
//线程优先级
demo01.setPriority(1);
demo02.setPriority(3);
demo03.setPriority(7);
demo04.setPriority(10);
demo01.start();
demo02.start();
demo03.start();
demo04.start();
}
}