HELP! * GREY=local LOCAL HTML version of Foils prepared 29 January 1996

Foil 78 Threads as Discussed in Sun's Tutorial

From CPS616 Lectures on Java CPS616 Basic Information Track for Computational Science -- Winter-Spring Semester 96. by Geoffrey C. Fox * See also color IMAGE

One can implement threads in two ways
  • Firstly subclassing the Thread class and overriding its run() method
  • Secondly by creating a Thread with a Runnable object (i. e. that implements Runnable interface)
Only the second way is possible for applets as these already extend Applet class and so cannot multiply inherit from the Thread class
Threads must have a run method which is code Thread executes.
If you are using first way, this is written for this particular thread and overrides run() in Thread class
In second way, the created Thread automatically takes its run() method to be the run method of the applet



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 Tue Feb 18 1997