| Author |
Thread priority
|
P Ventura
Ranch Hand
Joined: Jan 24, 2007
Posts: 42
|
|
Source JQPLUS. If a Thread's priority is not specified explicitly then it gets a priority of Thread.NORM_PRIORITY. I answered true, but jqplus response was false because: "Similar question has been asked in SCJP2. In such a case, the Thread gets the same priority as the thread that has created it. So if a thread t1 having a priority Thread.MAX_PRIORITY creates a thread t2, t2 will also get a priority of Thread.MAX_PRIORITY......" I remember something about on K&B saying that a new thread always has NORM_PRIORITY. I also tried this code that print 10(Maxpriority (I know that depends on JVM)) 5 (norm_priority )". What is the correct answer?
|
Objective: SCJP 1.5<br /><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" target="_blank" rel="nofollow">API</a><br /> <blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre><font size="2"><br />Double n1 = Double.NaN; Double n2 = Double.NaN;<br /> n1.equals(n2) // true even though Double.NaN != Double.NaN<br />-0.0 == +0.0; // true<br />Double n1 = -0.0;Double n2 = +0.0;<br />n1.equals(n2) // false even though -0.0 == +0.0<br /></font></pre><hr></blockquote>
|
 |
Kelvin Chenhao Lim
Ranch Hand
Joined: Oct 20, 2007
Posts: 513
|
|
Hi P, Quick tip: when you find yourself needing answers to queries like this one, you may find it a lot faster to check out the API javadoc for the class in question. For example, here's the appropriate paragraph from the Thread javadoc: "When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread, and is a daemon thread if and only if the creating thread is a daemon."
|
SCJP 5.0
|
 |
 |
|
|
subject: Thread priority
|
|
|