This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread priority Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread priority" Watch "thread priority" New topic

thread priority

Dhanashree Mankar
Ranch Hand

Joined: Aug 25, 2003
Posts: 123
Thread t = new Thread();
what will be the pririty of this thread?is it normal or inherited from parent?
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
From the Java API for class Thread.

The priority of the newly created thread is set equal to the priority of the thread creating it, that is, the currently running thread. The method setPriority may be used to change the priority to a new value.

Moreover, we ain't got many rules 'round these parts, but we do got one. Please change your displayed name to comply with the JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[Blog] [Blogroll] [My Reviews] My Linked In
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
If a thread priority is not specified explicitly, it would inherit the priority of the thread it was created in. So if you had a main thread, with the default priority of 5, and you created your thread from within it, then the new thread would also have the same priority of 5. But lets say if you changed the priority of the main thread to say 8, then the thread you create will also have the priority of 8.
I hope this is helpful. Also check this thread link on the forum for a small example
I agree. Here's the link:
subject: thread priority
It's not a secret anymore!