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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
Code:
----------------------------------------------------------
What is the default priority of a thread?Select one correct answer.

Depends upon Operating System.
The default priority is 1.
The default priority is 5.
The default priority is 10.
------------------------------------------------------------

Can anybody answer it?
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
I Think Default priority is inherited from parent thread
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

----------------------------------------------------------
What is the default priority of a thread?Select one correct answer.

Depends upon Operating System.
The default priority is 1.
The default priority is 5.
The default priority is 10.
------------------------------------------------------------

Can anybody answer it?

Yes.

And you can too, with a minimal amount of searching. Hint: Look for the constant field value of Thread.NORM_PRIORITY in the API.
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

I Think Default priority is inherited from parent thread
That is correct; however, one might feasibly ask for the default priority of the parent, and so on...

If you don't specifically set a priority, there *is* a default priority.

http://www.google.com/search?q=java+thread+default+priority
harish shankarnarayan
Ranch Hand

Joined: Sep 12, 2005
Posts: 158
hi
i have read that the default priority of the thread is 5.
wats the correct ans if its wrong how to determine it.
can anyone throw some light on priorities of thread.


Harish<br />SCJP 1.4 (85%)
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
For every thread it is not 5.for garabage collector thread it can be lessthan 5.......and so on.But you can explicitly set it
final void setPriority(int)
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

i have read that the default priority of the thread is 5.
wats the correct ans if its wrong how to determine it.
can anyone throw some light on priorities of thread.

That is correct, per the Thread API.
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

The Java� Programming Language (3rd Ed.) has this to say:

A thread's priority is initially the same as the priority of the thread that created it. The priority can be changed using setPriority with a value between Thread's constants MIN_PRIORITY and MAX_PRIORITY. The standard priority for the default thread is NORM_PRIORITY. The priority of a running thread can be changed at any time. If you assign a thread a priority lower than its current one, the system may let another thread run, because the original thread may no longer be among those with the highest priority. The getPriority method returns the priority of a thread.

Note: Do *not* - I repeat do *not* - rely on the behavior of the thread scheduler.

Hope this helps...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threads