我是靠谱客的博主 酷酷酒窝,这篇文章主要介绍修改线程优先级,现在分享给大家,希望可以做个参考。

public class De2 extends Thread {
    @Override
    public void run() {
        System.out.println("子线程的名字:"+Thread.currentThread().getName()+"优先级:"+Thread.currentThread().getPriority());
    }
}

public class De2T {
    public static void main(String[] args) {

    Thread thread = Thread.currentThread();
        System.out.println("主线程的名字"+thread.getName()+"优先级:"+thread.getPriority());
        De2 de2 = new De2();
        System.out.println("子线程的名字:"+de2.getName()+"优先" +
                "级:"+de2.getPriority());
        System.out.println("修改后的优先级");
        thread.setPriority(Thread.MAX_PRIORITY);
        System.out.println("主线程的名字"+thread.getName()+"优先级:"+thread.getPriority());
        de2.setPriority(Thread.MIN_PRIORITY);
        System.out.println("子线程的名字:"+de2.getName()+"优先" +
                "级:"+de2.getPriority());
    }
}

 

最后

以上就是酷酷酒窝最近收集整理的关于修改线程优先级的全部内容,更多相关修改线程优先级内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(151)

评论列表共有 0 条评论

立即
投稿
返回
顶部