This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread priority" Watch "thread priority" New topic
Author

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
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
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)
Bill


Java Resources at www.wbrogden.com
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: 1088
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: http://aspose.com/file-tools
 
subject: thread priority
 
Similar Threads
yield
Thread2
Thread.yield
How to run tasks with priority?
Thread Priority