public class Demo03 {
/**
* 线程的优先级:
* 设置线程优先级的作用:保证优先级高的线程被调度的概率最大
*
*
*/
public static void main(String[] args) {
MyT1 t1=new MyT1("aaa");
MyT1 t2=new MyT1("bbb");
t1.setPriority(Thread.MIN_PRIORITY);
t2.setPriority(10);
t1.start();
t2.start();
}
static class MyT1 extends Thread{
public MyT1(String name)
{
super(name);
}
@Override
public void run() {
for(int i=0;i<1000;i++)
{
System.out.println(Thread.currentThread().getName()+"----i="+i);
}
}
}
}