This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threading - Default priority Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threading - Default priority" Watch "Threading - Default priority" New topic
Author

Threading - Default priority

Thomas De Vos
stable boy
Ranch Hand

Joined: Apr 12, 2003
Posts: 425
The JDK docs 1.4.2 does not mention anymore the default priority as 5, this has been removed.
Previous Javadocs did contain as NORM priority the value of 5. However when you create a Thread the getPriority() returns 5. The priority is actually assigned from the parent priority (i.e. the creating Thread), and it is the scheduler that will decide which Thread to run.
I'm wondering if something has been changed to the implementation!?


Try your free <a href="http://www.javacertificate.com" target="_blank" rel="nofollow">SCJP 1.4</a> certification centre.<br />Try your free <a href="http://www.j2eecertificate.com" target="_blank" rel="nofollow">SCWCD</a> certification centre.<br />Try your free <a href="http://www.ejbcertificate.com" target="_blank" rel="nofollow">SCBCD</a> certification centre.<br />Try your <a href="http://www.webspherecertificate.com" target="_blank" rel="nofollow">Websphere (Test 285) </a> certification centre.<br />Try your <a href="http://www.j2mecertificate.com" target="_blank" rel="nofollow">SCMAD</a> certification centre. (New)<br /> <br /><a href="http://blogs.javacertificate.com" target="_blank" rel="nofollow">Java/J2EE Certification Blogging</a>
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The API still refers to NORM_PRIORITY: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Thomas De Vos
stable boy
Ranch Hand

Joined: Apr 12, 2003
Posts: 425
Indeed but it does not mention anymore that the default priority is 5.
Thomas De Vos
stable boy
Ranch Hand

Joined: Apr 12, 2003
Posts: 425
Only if you look to the actual values.
Still wondering what has been changed.
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi
It proabably doesn't refers to 5 because some implementations of java may have a different NORM_PRIORITY. Say 3 or something else.
[ May 27, 2003: Message edited by: Anupam Sinha ]
Thomas De Vos
stable boy
Ranch Hand

Joined: Apr 12, 2003
Posts: 425
The book from Kathy and Bert does mention that the default priority is 5. Sybex book mentions also that the defualt priority is 5.
I'm aware that the actual implementation can change and that the OS threading mechanism needs mapping to the actual values implemented by the JVM, but the Java language definition default priority is 5.
Conclusion: The values of the Java implementation are not one to one mapped to the JVM's implementation.
I believe that for the exam the default priority is 5, that is what the actual Java implementation is.
Any comments ...
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Thomas
5 is not the default priority. But 5 can be the default priority. That is, if the parent thread has a priority of 5. Secondly there might be a java compiler lets say from XYZ that doesn't uses the NORM_PRIORITY as 5 but likes it to be 3. XYZ may choose to this because they might be having the priorities in the range of MAX_PRIORITY(1) to MIN_PRIORITY(7). So this might be a reason that java refers to the constant NORM_PRIORITY.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threading - Default priority