Basic HTML version of Foils prepared March 26 1999

Foil 18 Threads

From Java Academy:Graphical User Interface NPAC Java Academy February--April 99 -- March 1999. by Nancy McCracken


1 If you write the animation with a loop that keeps drawing new images of graphics objects, you cause a problem for the browser by having a long computation. (The browser will either freeze the window or eventually crash.)
2 This can be fixed by creating a Thread and putting the continual loop into a method called run that is the computation of the Thread. The run method is then executed independently of the browser on the computer. Thread thread = new Thread ( this );
3 Create a run method in the same class as the thread: public void run ( ) { // put the continual loop in the body }

in Table To:


© 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 Fri Mar 26 1999