File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "threads" Watch "threads" New topic
Author

threads

gpk thiru
Greenhorn

Joined: Oct 28, 2004
Posts: 3
# 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

Joined: Oct 23, 2004
Posts: 151
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

Joined: Oct 28, 2004
Posts: 3
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

Joined: Oct 23, 2004
Posts: 151
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
 
subject: threads