Thread
public static void main(String[] args) {
Thread th1 = new Thread(new Runnable() {
public void run() {
val = "thread by th1!";
System.out.println(val);
}
});
Thread th2 = new Thread(new Runnable() {
public void run() {
val = "thread by th2!";
System.out.println(val);
}
});
//设置优先级
th2.setPriority(Thread.MAX_PRIORITY);
th1.setPriority(Thread.MAX_PRIORITY-1);
th1.start();
th2.start();
}