package com.yys.thread; /** * Created by yys on 2017/9/20. * 测试 Thread setPriority方法 * 设置线程优先级 * 输出为 T1 : 7488 T1 : 7489 ---T2 : 5 T1 : 7490 T1 : 7491 */ public class TestPriority { public static void main(String[] args){ Thread t1 = new Thread(new T1()); Thread t2 = new Thread(new T2()); t1.setPriority(Thread.NORM_PRIORITY + 3); t1.start(); t2.start(); } } class T1 implements Runnable{ @Override public void run() { for(int i=0;i<=10000;i++){ System.out.println("T1 : " + i); } } } class T2 implements Runnable{ @Override public void run() { for(int i=0;i<=1000;i++){ System.out.println("---T2 : " + i); } } }
最后
以上就是淡淡大山最近收集整理的关于JAVA多线程Thread setPriority 设置线程优先级方法入门详解的全部内容,更多相关JAVA多线程Thread内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复