It's not a secret anymore!
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


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: 141
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.
I agree. Here's the link:
subject: setDaemon
It's not a secret anymore!