Previous | Next | Trail Map | Writing Applets | Overview of Applets


Threads in Applets: Good Example

Note: If you've already looked at this page, reload the applet to see the example again.

The following applet (named Good) has a computation-intensive beginning sequence, implemented as a loop that occasionally prints status. The Good applet does the right thing: Instead of putting the loop in the init() or start() method, it spins off a thread to do the computation. (Here's the source code.) Notice how quickly (compared to the Bad applet) the browser can display the applet and the rest of the page.


Previous | Next | Trail Map | Writing Applets | Overview of Applets