Using user stream conversion & # 8594; stream daemon

I read, daemon threads are used and managed by the JVM. The JVM creates them and also tracks their completion. User streams are user controlled. It also says that we can convert a user stream to a daemon stream by calling the setDaemon() method.

But, what is the use of such conversion ? Does the JVM approach a user thread when it becomes a dameon thread?

Let me know if I missed something.

Thanks.

+4
source share
2 answers

I believe that user and daemon flows are always under the control of the JVM. (If this were not so, who would answer?)

Here's the difference (from http://www.xyzws.com/javafaq/what-is-difference-between-user-and-daemon-thread-in-java/196 ):

The difference between the two types of threads is simple: if Java Runtime determines that only threads running in the application, daemon threads (i.e. no user threads), Java runtime quickly closes applications, effectively stopping all daemon threads dead in their tracks . In order for the application to continue to work, it must always have at least one user stream. In general, other aspects that the Java runtime uses daemon threads and user threads in exactly the same way.

+7
source

Daemon themes do not prevent the application from closing while they are still running. They are more suitable for tasks that need to be performed while the application remains alive, but it is safe to kill otherwise.

+7
source

Source: https://habr.com/ru/post/1338138/


All Articles