• 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 issue

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


here i am setting thread priority to 2 threads max priority to second thread and min proprity to 1st thread but the 2nd thread is not running first

why?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i remember correctly using thread priorites is at the discretion of the OS.

Consider using your own thread scheduler.
[ September 27, 2006: Message edited by: Amit A. Patil ]
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As your run() method does so little, one could not reasonably expect priority to have much effect. In fact, t1 may have started and finished, before the t2.start() statement even runs.

As previous poster has pointed out, Java makes few promises about exactly what thread priorities will do. This is to accommodate different platforms. In practice, however, JVMs on major OSs will respect priorities reasonably well. But, to see it, you'd need to give the threads worthwhile work to do: something that takes a few seconds (and don't use sleep(), wait() etc. because that's not work).
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take 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