> Guys,
>
[quoted text clipped - 17 lines]
> ...
> }
To be able to access the data in the print task, you can either pass an
instance into the PrintDataTask constructor or use "setter" method to
set the data to be printed.
import java.util.TimerTask;
public class PrintDataTask extends TimerTask {
private MasterData data;
public PrintDataTask() {
}
public PrintDataTask(MasterData data) {
this.data = data;
}
public MasterData getData() {
return data;
}
public void run() {
if (data != null) {
data.print();
}
}
public void setData(MasterData data) {
this.data = data;
}
}
Then your mainApp could be like this:
> class mainApp {
private final static long ONE_MINUTE_IN_MILLIS = 60L * 1000L;
> public static void main(String[] args)
> {
> MasterData data=new MasterData();
Timer taskTimer = new Timer();
PrintDataTask printTask = new PrintDataTask(data);
taskTimer.schedule(printTask, 2000, ONE_MINUTE_IN_MILLIS);
> while(true)
> {
[quoted text clipped - 4 lines]
>
> // Ending of code.
The printTask's run method will be called the first time after 2 seconds
(2000 millisecs), and then every minute.
You may need to synchronize the access to the data, i.e. make sure that
the data is not updated while it's being printed by the print task.
Instead of the while-true loop for updating the data, you might consider
to use a scheduled task too, but with much smaller interval than the
print task.

Signature
Regards,
Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \