我把t1的线程优先级设置到最高,为什么有时候刚启动运行t2会比t1先执行?
新手 求指教!顺便求技术分!嘿嘿!{:3_62:}
- public class ThreadTest4{
- public static void main(String[] args) {
- Thread t1=new Thread(new runner5());
- Thread t2=new Thread(new runner6());
- t1.setPriority(Thread.MAX_PRIORITY);
- t1.start();
- t2.start();
- }
- }
- class runner5 implements Runnable{
- public void run() {
- for (int i = 1; i <= 100; i++) {
- System.out.println("t1:"+i);
- }
- }
- }
- class runner6 implements Runnable{
- public void run() {
- for (int i = 1; i <= 100; i++) {
- System.out.println("-----t2:"+i);
- }
- }
- }
复制代码
|