From a programmer’s perspective, an applet has four stages to its life cycle. They are defined by the following four methods that are called by the browser as the applet is loaded and run:
This is called just after an applet is created and before the applet is displayed in the browser. It is normally used to perform any initialization that should take place only once in the life cycle of the applet. This includes the creation of a thread to run the applet.
This is called when the applet becomes visible in your browser and is used to start the thread that runs the applet.
This is called when the applet is no longer visible. When this method is called, a well behaved applet will put its thread to sleep, or stop the thread entirely, in order to conserve computer resources.
This is called when the applet is purged from your browser’s memory cache. It is used to stop the applet’s thread and to release any other computer resources the applet may be using.
The choice of which of these methods you use to open and close a
database connection is not straightforward. You must consider how you
will use the connection within your applet. If your applet will open
a database connection, retrieve some data, then close the connection,
and do this only once, you may wish to perform these functions in
init( ), as part of
or in a method you create that is in turn run by the thread you start
start( ) method. If your applet ...