• 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

Thread Priority can be changed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Learnt today that thread priorities can be changed.
Used to think it will throw IllegalStateException once set.
FYI if JVM gives higher thread priority prints "A A A" always first.

class ThreadTest extends Thread
{
ThreadTest(String name){super(name);}
public void run(){
for(int i=0;i<100;i++){
System.out.println(this.getName());

}
}
public static void main(String[] args)
{
ThreadTest a=new ThreadTest("A A A ");
ThreadTest b=new ThreadTest("B B B ");
a.setPriority(Thread.MIN_PRIORITY);
a.start();
b.start();
a.setPriority(Thread.MAX_PRIORITY);

}
}
 
Ranch Hand
Posts: 51
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Thread priority changing is something Java provides. Selection methodology of a Thread to RUN from the READY_TO_RUN state is dependent on the Plateform you run your program.

----------
Regards,
Kamal
SCJP 1.4
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic