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?
What exactly is the
problem? But even without knowing the nature of the problem, I would recommend
the following changes in green.
public class chartApplet extends Applet
implements Runnable {
Thread thread = null;
void drawChart() {
}
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){ break;
};
drawChart();
}
}
public void init() {
now =
System.currentTimeMillis();
setLayout(new
GridLayout(1,1));
drawChart();
}
}