This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Priority issue

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • 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?
 
Amit A. Patil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • 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 ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • 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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic