Daemon Threads provide services for user threads, apart from gc
What is another example (case) where a daemon thread can be used? (Any task(logic) that can be inside the run()
method of a daemon
Thread
in practice)
Here is a short list of when you may want to use a daemon thread:
Sounds like an assignment question ha ha.
You can also use them for IO because IO operation block and its best to do that in a worker thread.
Also network activity if you are waiting for things to download etc. like the response to a post request.
Daemon threads are typically used to perform services for your application/applet (such as loading the "fiddley bits"). The core difference between user threads and daemon threads is that the JVM will only shut down a program when all user threads have terminated. Daemon threads are terminated by the JVM when there are no longer any user threads running, including the main thread of execution.
In short: daemon threads do not keep the program from quitting; user threads keep the program from quitting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With