answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: How do you terminate daemon thread?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is main method a thread?

No, Main is not a daemon thread in Java. its a non daemon or user thread. Also any thread stem from Main will be non daemon because daemon is derived from parent Thread status.


What are the features of daemon thread in java?

Any Java thread can be a daemon thread. Daemon threads are service providers for other threads running in the same process as the daemon thread. For example, the HotJava browser uses up to four daemon threads named "Image Fetcher" to fetch images from the file system or network for any thread that needs one. The run() method for a daemon thread is typically an infinite loop that waits for a service request. When the only remaining threads in a process are daemon threads, the interpreter exits. This makes sense because when only daemon threads remain, there is no other thread for which a daemon thread can provide a service. To specify that a thread is a daemon thread, call the setDaemon() method with the argument true. To determine if a thread is a daemon thread, use the accessor method isDaemon().


What is daemon thread in java?

Daemon thread is a kind of thread that does not prevent the JVM from exiting when the thread is still running while the program finishes. A good example of this is the garbage collection.


How do you terminate a thread which is continuously executing?

A thread that is continuously executing has an infinite loop. To terminate that thread you must break that loop by providing a suitable terminating condition. If the thread is a "worker" thread, the main thread should signal all worker threads to terminate when the main thread terminates. The main thread should remain active until all worker threads have successfully terminated.


If a process terminates will its thread also terminate?

yes, because if process is terminated then its related thread has no work. After completion of process the kernel generates a thread that will cancelled the thread in order to save the time and memory of CPU.


What happens to child thread when you delete main thread during run-time?

In Java, if the main thread somehow exits then all other threads will stop executing. This generally does not happen, as the main thread will wait for all child threads to terminate before the main thread itself finishes. Interrupting this process is hard to do short of an un-handled exception or a call to System.exit. If the child thread is also a daemon thread, then the child thread will continue to execute. If the child thread is a normal thread then, the moment System.exit is called, the child thread also terminates If you call the join() method from the child thread, then the main thread will wait until the child is over before executing the System.exit


If a process terminates will its thread also terminates?

Yes, the thread will also terminate if the process it is running in terminates. The thread is dependent upon the processes it is running. If the processes die the thread dies.


What is a daemon thread?

A daemon thread is often called a "service thread" or a "nonessential thread". The other kind of thread is often called a "user thread."The JVM will exit when all user threads have returned from their run methods. Once all of the user threads have returned, any active daemon threads will be forced to stop running.Let's look at an abstract example to see the difference... Pretend you have written a client-server GUI-based chat client. You'll typically have at least one thread sitting around and listening for input from the other program (the server will listen for input from the client and the client will listen for input from the server). These threads can be set as daemon threads, because you don't want the JVM to keep executing if those are the only threads left.Not let's look at the GUI for your programs. These will be run in a user thread, since you want to make sure that the JVM does not exit until the GUI thread finishes running (you will generally stop these threads from running when the user clicks to close the window).


What are the methods to forcibly terminate a thread?

To end a thread within the thread's own code you can also simply return from the thread function or method. However if you want to terminate a thread from code which is running outside of the thread's own flow you must typically code a mechanism of your own to do this. A simple way to do this is to have the threaded code check a shared signal variable every so often, if the variable is signaled - then the threaded code exits and the thread dies. Terminating a process (in C with say exit(..) ) will typically force the closing of any associated threads.


How to write daemons using threads instead of using fork as there are certain conditions in which a process is called a daemon?

A "daemon" is a general English term for a process that is meant to run forever in the background, without access to a display terminal. Threads are subcomponents of processes. It is not possible to run as an isolated "thread". Every process contains at least one thread, but can contain more if programmed correctly. Threaded programming typically is done so that a master or "manager" thread listens for an indication of incoming work to be done, and then dispatches this work to a new "worker" thread to handle the work, freeing the manager thread to listen for more incoming work.


Where can you purchase Daemon tools?

Daemon Tools can be purchased at Daemon's official website.


What is Will's daemon called?

Will's daemon is named Kirjava.