线程的优先级(Thread类中)
1、线程优先级级别
线程默认优先级是5。范围是1-10
Thread.MAX_PRIORITY //10
Thread.MIN_PRIORITY //1
Thread.NORM_PRIORITY //5
2、方法
public final int getPriority():获取线程优先级
public final void setPriority(int newPriority):更改线程的优先级
3、注意
优先级可以在一定的程度上,让线程获较多的执行机会
4、举例
MyThread t = new MyThread();
System.out.println(t.getPriority());
t.setPriority(Thread.MAX_PRIORITY);
|
|