Java applets have life cycle methods. These are init
, start
, stop
and destroy
. You must learn how to use them, but more importantly, you must find out when the browser calls each of these methods.
When you go from your page, stop
is called, and you must stop the threads that you started at start
, and the cleanup resources if you allocated them. Browsers do not kill the JVM every time the page is reloaded, because it will be extremely inefficient (and for other reasons), so if you want to stop everything your applet does, inject it into the stop
method.
Also see here and other links on this page for further explanation.
source share