public class scroll extends Applet implements Runnable
{
Thread countDownCalTd;
calObj countDownCal;
public void init()
{
countDownCal = new calObj();
Thread countDownCalTd = new Thread(countDownCal);
countDownCalTd.start();
}
public void run()
{
access method or variable from the thread of countDownCalTd
...
}
}
class calObj extends Object implements Runnable
{
public Calendar cal = Calendar.getInstance();
public boolean shouldLoop = true;
public int currentSec;
public int alarm()
{
return currentSec;
}
public void run()
{
while(shouldLoop)
{
cal = Calendar.getInstance();
currentSec = cal.get(Calendar.SECOND);
}
...
}
}
Can I call the method alarm() from the applet directly or access the variable currentSec from applet.
I need the applet running two threads concurrently. Thanks for any help!
cheungchin
{
Thread countDownCalTd;
calObj countDownCal;
public void init()
{
countDownCal = new calObj();
Thread countDownCalTd = new Thread(countDownCal);
countDownCalTd.start();
}
public void run()
{
access method or variable from the thread of countDownCalTd
...
}
}
class calObj extends Object implements Runnable
{
public Calendar cal = Calendar.getInstance();
public boolean shouldLoop = true;
public int currentSec;
public int alarm()
{
return currentSec;
}
public void run()
{
while(shouldLoop)
{
cal = Calendar.getInstance();
currentSec = cal.get(Calendar.SECOND);
}
...
}
}
Can I call the method alarm() from the applet directly or access the variable currentSec from applet.
I need the applet running two threads concurrently. Thanks for any help!
cheungchin