• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread priority

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic