wood burning stoves 2.0*
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


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread priority" Watch "thread priority" New topic
Author

thread priority

Dhanashree Mankar
Ranch Hand

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

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!


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Hi,
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
Regards,
Anupreet
 
GeeCON Prague 2014
 
subject: thread priority