Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Threads and Synchronization and the fly likes setDaemon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "setDaemon" Watch "setDaemon" New topic
Author

setDaemon

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84


when i run this code it generates IllegalThreadStateException in runtime
how can i rectify this

"I Love Java Ranch"
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Have you read the documentation? Because the answer is right there.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 93
setDaemon() has to be specified before the execution of the thread.start() method.

While the thread is executing specifying the thread as daemon is not allowed.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: setDaemon