這個程序驗證了後台線程與用戶線程的區別以及之間的關系
import ncurrent
public class Test {
public static void main(String[] args){
//將主線程的優先級設為最低
Thread
Thread myThread=new Thread(new Runnable(){
public void run(){
while(true)
{
System
try {
TimeUnit
} catch (InterruptedException e) {
e
}
}
}
});
myThread
myThread
myThread
Thread userThread = new Thread(new Runnable(){
public void run(){
for(int i=
System
}
});
userThread
userThread
System
}
}
在上面的程序中就能體會到
這裡要注意一點
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27398.html