Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread priority

 
Damien Howard
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Damien Howard
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is a daemon and how/why do you use or need them?
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic