class Priority extends Thread{
int num;
public Priority(int num){
this.num=num;
}
public void run(){
for(int count=0;count<=num;count++){
System.out.println("Count is "+count);
}
System.out.println(Thread.currentThread().getName());
System.out.println("Its Priority was : "+Thread.currentThread().getPriority());
Thread.currentThread().setPriority(MAX_PRIORITY);
System.out.println("Its Priority now is : "+Thread.currentThread().getPriority());
}
public static void main(String a[]){
for(int ctr=0;ctr<2;ctr++){
Priority obj=new Priority(5);
obj.start();
obj.setName("Thread "+(ctr+1));
}
}
}
No comments:
Post a Comment