Hi all... I make this thread applet to draw a chart so that everytime the data changes, the chart changes automatically.
I have implement the Runnable for the applet and here's the code for
start(), run(), stop(), and init() ... can anybody tell me what's wrong?
 
public class chartApplet extends Applet implements Runnable {
 
  Thread thread = null;
 
  void drawChart() {
    //implementation of drawing a chart
  }
 
  public void start() {
    if (thread==null){
   thread = new Thread(this);
   thread.start();
    }
  }
 
  public void stop() {
    if (thread!=null){
   thread.stop();
   thread=null;
    }
  }
 
  public void run() {
    while (thread!=null) {
      try {thread.sleep(1000*60);}
      catch (InterruptedException e){};
      drawChart();
    }
  }
  public void init() {
    now = System.currentTimeMillis();
    setLayout(new GridLayout(1,1));
    drawChart();
  }
 
}

Reply via email to