• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused about priority system

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
------------------
 
Golam Newaz
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry i did a mistake in example. The first line
should be the followings:
class Prioritytest extends Thread{
Thanks,
- Golam Newaz
------------------
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic