The moose likes Java in General and the fly likes Daemon Thread. Aplication - Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Daemon Thread. Aplication - Applet" Watch "Daemon Thread. Aplication - Applet" New topic
Author

Daemon Thread. Aplication - Applet

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Is there any difference between using setDaemon(true) method in an application
and a applet.

I created a Thread in the constructor and made setDaemon(true) and called start() method and inside run method I call other methods in the application. Unfortunately the application runs to completion before making a call to other methods of the class.

This happens because Daemon thread are there to serve the user threads, So Once there is no user thread the application ends.

My question is then why does the same is not happening in Applet.

I created a thread and made setDaemon(true) in the init() method and called the start() method and inside run method I call other methods in the applet. This is working fine. How this is happening ?


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

Because the JVM doesn't exit -- it's running inside the browser, and stays running. Your applet gets destroyed, including all the Threads, but just because your threads end, this doesn't mean the JVM will exit.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Daemon Thread. Aplication - Applet
 
Similar Threads
Question from exam on Daemon thread
what is a Daemon Thread
Thred Should run even after Program terminates
need clarification on threads
Thread