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 ?
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.