class TestPriority{
public static void main(String args[]){
Thread catThread=new ExThread("catThread",50);
Thread dogThread=new ExThread("dogThread",15);
catThread.setPriority(7);
dogThread.setPriority(1);
catThread.start();
dogThread.start();
}
}
class ExThread extends Thread{
private int num;
public ExThread(String str,int n){
super(str);
num=n;
}
public void run(){
for(int i=0;i<num;i++){
System.out.print(getName()+"");
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น