File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes A question about java thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A question about java thread" Watch "A question about java thread" New topic

A question about java thread

James Tan

Joined: Apr 23, 2002
Posts: 13
The priority of a Newly created Thread can be changed by the method
public final void setPriority(int newPriority) ? True/False?
The answer is false, and explain as below
The priority of a newly created Thread depends on the Thread that created it。

But I think the answer explains an another concept and "true" should be the answer.

James Tan<br />SUN Certificated Programmer
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
The initial priority of a new thread is indeed set equal to the priority of the thread that created it. However, the priority of a thread can be changed using the Thread.setPriority method after the new thread is created.
The following is quoted from the javadoc of the Thread class.

public final void setPriority(int newPriority)
Changes the priority of this thread.
First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException.
Otherwise, the priority of this thread is set to the smaller of the specified newPriority and the maximum permitted priority of the thread's thread group.

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="" target="_blank" rel="nofollow">Try my mock exam.</a>
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

I agree. Here's the link:
subject: A question about java thread
It's not a secret anymore!