This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
# 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?
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?
Joined: Oct 28, 2004
J, thanks for your response..... no i can't think of a situation where both these stmts become true
Joined: Oct 23, 2004
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.