Java如何设置线程的优先级呢?
实现思路:
使用setPriority()方法可设置线程的优先级
例:
public class testThread extends Thread {
public testThread (int priority) {
setPriority(priority);
start();
}
}
public static void main(String[] args) {
new testThread(Thread.MAX_PRIORITY);
}
}
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。