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 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

thread priority

Damien Howard
Ranch Hand

Joined: Apr 01, 2003
Posts: 456
This may be my imagination, but I thought I read somewhere that you have to use setpriority before starting a thread assuming you want to change its priority and not use the default one.
Can someone clarify?
And if this is indeed the case, what about if for some reason you want the thread to drop in priority for some reason?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You can do a setPriority any time.
It is the setDaemon method that you have to call before the Thread is started.
(also - remember that priority is inherited from the Thread that creates a Thread)
Damien Howard
Ranch Hand

Joined: Apr 01, 2003
Posts: 456
What exactly is a daemon and how/why do you use or need them?
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1090
Hi Damien
The setDaemon() is used to make a thread as daemon. Daemon threads are not required to finish processing in order for the JVM to exit, in case all non-daemons threads have been completed. That is the JVM may exit in case if all the threads that are left are daemon threads.
setDaemon(boolean) can only be called before the thread is started.
Try this link
I agree. Here's the link:
subject: thread priority
jQuery in Action, 3rd edition