Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread priority

 
P Ventura
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic