Starting the Thread
In this applet, the runner thread starts when the applet’s start() method is called and stop when its stop() method is called.
The start() method is called right after the init() method and every time the program is restarted. Here’s the method:
public void start() { if (runner == null) { runner = new Thread(this); runner.start(); }}
This method starts the runner thread if it is not already started.
The statement runner = new Thread(this) creates a new Thread object with one argument—the this keyword. The this keyword refers to the applet itself, designating it as the class that runs within the thread.
The call to runner.start() causes the thread to begin running. When a thread begins, the run() method ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access