/*
线程优先级
优先级:1-10
最低:1
最高:10
默认:5
*/
public class fuck3{
public static void main(String[] args){
Thread t1=new professor();
t1.setName("t1");
Thread t2=new professor();
t2.setName("t2");
//获取优先级
t1.getPriority();//5
t2.getPriority();//5
//设置优先级
t1.setPriority(1);
t2.setPriority(10);
//启动线程
t1.start();
t2.start();
}
}
class professor extends Thread{
public void run(){
for(int i=0;i<50;i++){
System.out.println(Thread.currentThread().getName()+"-->"+i);
}
}
}
线程优先级
优先级:1-10
最低:1
最高:10
默认:5
*/
public class fuck3{
public static void main(String[] args){
Thread t1=new professor();
t1.setName("t1");
Thread t2=new professor();
t2.setName("t2");
//获取优先级
t1.getPriority();//5
t2.getPriority();//5
//设置优先级
t1.setPriority(1);
t2.setPriority(10);
//启动线程
t1.start();
t2.start();
}
}
class professor extends Thread{
public void run(){
for(int i=0;i<50;i++){
System.out.println(Thread.currentThread().getName()+"-->"+i);
}
}
}
1060

被折叠的 条评论
为什么被折叠?



