• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic