posted 12 years ago
A daemon thread is similar to any other thread in java. But, if a thread is set as a daemon, it will keep running till there is at least one non daemon user defined thread running. Once all the non daemon user defined threads stop, the daemon threads will automatically stop.
We can use this, for example, to run monitor threads on applications. After all the processing is done when all the user defined non daemon threads stop, the daemon thread will automatically stop and shut down the JVM. If this monitor thread is not a daemon, the JVM will still be running because of it, though the processing is complete.
They say you have to be the first, the best or different. I say, is it too much to ask for all three.