Basic HTML version of Foils prepared May 12 1996

Foil 95 Sun's Digital Clock Applet to Illustrate Threads -- II

From CRPC Lectures on Java Language Applets Graphics CRPC Annual Meeting Tutorial -- May 14,1996. by Geoffrey C. Fox


1 public void run () {
2 while (clockThread !=null) {
3 repaint ();
4 try { clockThread.sleep(1000);
  • } catch (InterruptedException e) { }
5 } // end while
6 } // end run()
7 public void paint (Graphics g) {
8 Date now = new Date ();
9 g.drawString (now.getHours() + ":"+ now.getMinutes() + ":"+now.getSeconds(), 5, 10);
10 }
11 public void stop () {
12 clockThread.stop();
13 clockThread = null;
14 }
15 } // End Digital Clock Applet

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 Sun Dec 14 1997