File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes setPriority()? 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 "setPriority()?" Watch "setPriority()?" New topic


Calanthe Wei
Ranch Hand

Joined: Oct 27, 2001
Posts: 42
Can calling the setPriority method cuase a thread to stop executing?
I am a little confused about the answer. Thank you for your explanation.
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
I guess that if the Thread.MIN_PRIORITY is set, any thread with the biggest priority could be chosen now.

SCJP2. Please Indent your code using UBB Code
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
The results of calling set priorirty on a thread will depend on how the operating system handles threads and priorities and also on other threads that are alive at any given point in time.
Let us say you have only one thread running, you can reduce it's priority all the way to min_priority and it will still continue to run.
Let us say you are running on an OS that implements preemptive scheduling and the current thread is set at priority 5, Let us also say that all other threads that are ready to run are at min_priority. If you reduce the priority of the current thread to 3, it will still continue to run.
You can not predict/guarantee the results of setting priority on a thread.
Hope this helps
I agree. Here's the link:
subject: setPriority()?
It's not a secret anymore!