File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Thread Priority issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread Priority issue" Watch "Thread Priority issue" New topic
Author

Thread Priority issue

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689


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?


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Amit A. Patil
Ranch Hand

Joined: May 04, 2006
Posts: 38
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

Joined: Oct 30, 2001
Posts: 1970
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).


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
 
subject: Thread Priority issue