Hi,
Kindly compile and run this program. I am confused about
thread priority. If i uncomment the try block then i get
message without priority system but with comments i
get message in priority system but does not follow acutal system like MAX, NORM, MIN. And also priority should be started before executing try block. But it doesn't work.
My Question:
1. does this example show that priority always depends on
platform?
2. When priority should be started in this example. Is before
try block or sleep() method stops priority system?
Example:
Prioritytest(
String s){
super(s);
}
public void run(){
for( int i=0; i<5; i++){
System.out.println(getName()+":"+ i);
}
}
}
public class testbyte{
public static void main( String argv[]) throws InterruptedException{
Prioritytest ab1=new Prioritytest("Say");
Prioritytest ab2=new Prioritytest("Sam");
Prioritytest ab3=new Prioritytest("Mee");
ab1.setPriority(Thread.MIN_PRIORITY);
ab2.setPriority(Thread.NORM_PRIORITY);
ab3.setPriority(Thread.MAX_PRIORITY);
ab1.start();
/* try{
Thread.sleep(3000);
}
finally{ } */
ab2.start();
/* try{
Thread.sleep(3000);
}
finally{ } */
ab3.start();
}
}
Need solution.
- Golam Newaz
------------------