SoundExample is featured in Playing Sounds . This page does not explain basic thread code. A typical example is an applet that performs timed animation, such as a movie player or a game. Animation applets need a thread that requests repaints at regular intervals. Another example is an applet that reads data supplied by a server-side application.
Applets typically create threads for repetitive tasks in the applet start method.
Creating the thread there makes it easy for the applet to stop the thread when the user leaves the page. All you need to do is implement the stop method so that it stops the applet's thread. When the user returns to the applet's page, the start method is called again, and the applet can again create a thread to perform the repetitive task. Below is AnimatorApplet 's implementation of the start and stop methods. It does so by implementing the java.lang Runnable interface, which requires the applet to provide a run method that forms the body of the thread.