This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threads

 
gpk thiru
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# What is the default priority of a newly created thread.

1. MIN_PRIORITY (which is defined as 1 in the Thread class.)
2. NORM_PRIORITY (which is defined as 5 in the Thread class.)
3. MAX_PRIORITY (which is defined as 10 in the Thread class.)
4. A thread inherits the priority of its parent thread.

i saw this question in a mock exam, there it says option 4 as the answer, but what i read was norm_priority is the default......can some one help me with this?

thanks
thiru
 
Joe Borderi
Ranch Hand
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both statements are true. A thread does inherit the priority of the thread that spawned it, and the default priority is NORM_PRIORITY. You are thinking of these statements as mutually exclusive.

Can you think of a situation that has both these statements true?
 
gpk thiru
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J,
thanks for your response.....
no i can't think of a situation where both these stmts become true

thanks
thiru
 
Joe Borderi
Ranch Hand
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gpk,

I didn't intend to be cryptic. Here is an example of a thread inheriting the priority of the thread that spawned it with the default NORM_PRIORITY: The main thread, by default has priority NORM_PRIORITY, and any thread that main (assuming that main's priority has not been reset) spawns will have as its default NORM_PRIOROITY.

If main or some other spawning thread has its priority set to another priority, any thread that is spawned from that spawning thread will have the spawning thread's priority by default. To change the spawned thread's priority, you must explicitly set the spawned thread's priority.

I see that the use of the term "inherit" may cause some confusion. I have found that the programming community often uses many of its buzz words to perform double duty. In this case, it may be that the coupling of "spawned" and "inherits" makes for a better poetic metaphor. I think, however, "initializes" more aptly describes the situation.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic