/*ch1005.java*/
import java.awt.*;
import java.applet.Applet;
import java.util.*;
import java.text.DateFormat;
public class ch1005 extends Applet implements Runnable
{
  Thread clockThread=null;
  public void init()
  {
    setBackground(Color.blue);
    setForeground(Color.yellow);
  }
  public void start()
  {
    if(clockThread==null)
    {
      clockThread=new Thread(this,"ch1005");
    }
  }
  public void run()
  {
    Thread myThread=Thread.currentThread();
    while(clockThread==myThread)
    {
      repaint();
      try
      {
        Thread.sleep(1000);
      }
      catch(InterruptedException e) { }
    }
  }
  public void paint(Graphics g)
  {
    Date date=new Date();
    DateFormat formatter=DateFormat.getTimeInstance();
    String str=formatter.format(date);
    g.drawString(str,5,10);
  }
  public void stop()
  {
    clockThread=null;
  }
}