1 
 2 public class TestPriority {
 3     public static void main(String[] args) {
 4         Thread t1 = new Thread(new T1());
 5         Thread t2 = new Thread(new T2());
 6         t1.setPriority(Thread.NORM_PRIORITY +3); //優先級設定
 7         t1.start(); t2.start();
 8     }
 9 
10 }
11 
12 class T1 implements Runnable {
13     public void run() {
14         for(int i=0;i<1000;i++){System.out.println("T1:"+i);}
15     }
16 }
17 
18 class T2 implements Runnable {
19     public void run() {
20         for(int i=0;i<1000;i++){System.out.println("------------T2:"+i);}
21     }
22 }
23