A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© codersun 中级黑马   /  2015-8-15 21:24  /  184 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

线程的优先级(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);

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马