Basic HTML version of Foils prepared Sept 21 1998

Foil 4 How to Use Threads

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

API to show relationship between Thread class and Runnable interface for Foil 4
One can implement threads in two ways:
  • First, by subclassing the Thread class
  • Second, by implementing the Runnable interface
A class that implements the Runnable interface (including the Thread class itself) must implement the run() method containing the "body" of the thread.
The Runnable interface makes it possible for an applet to utilize threads. (Remember, an applet extends the Applet class and so cannot multiply inherit from the Thread class.)



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998