Basic HTML version of Foils prepared Sept 21 1998

Foil 13 Example showing thread methods, continued

From Java Tutorial 98- 3: Graphics and the Abstract Windowing Toolkit NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

A digital clock with one thread
1 The body of the applet is in the run method, in this case a loop to keep showing the date.
2 public void run ( )
3 { while (true)
4 { theDate = new Date ( );
5 repaint ( );
6 try { Thread.sleep ( 1000); }
7 catch ( InterruptedExecution e) { }
8 }
9 }
10 public void paint ( Graphics g )
11 { g.setFont ( theFont );
12 g.drawString ( theDate.toString ( ), 10, 50 );
13 }
14 }

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 Sat Nov 28 1998