34、线程的优先级
程序员文章站
2022-06-10 14:15:49
...
class Person implements Runnable{
public void run(){
for (int i=0;i<20;i++){
System.out.println("线程1");
}
}
}
class Person2 implements Runnable{
public void run(){
for (int i=0;i<20;i++){
System.out.println("线程2");
}
}
}
public class Test{
public static void main(String[] args) {
Person p1=new Person();
Thread t1=new Thread(p1);
t.setName("线程1");
t.start();
Person2 p2=new Person2();
Thread t2=new Thread(p2);
t2.setName("线程2");
t2.start();
t2.setPriority((Thread.NORM_PRIORITY)+5);
}
}
上一篇: 移动端自适应
下一篇: 在Linux下改变进程的优先级