import java.util.ArrayList;
import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
import static java.lang.String.format;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.Timer;
+
public abstract class AWSThread
{
- private final Timer timer = new Timer();
+ private javax.swing.Timer timer;
/**
* view that this job was associated with
wsInfo.setFinishedNoResults();
return;
}
- TimerTask task = new TimerTask() {
+ timer = new Timer(5000, new ActionListener()
+ {
+
@Override
- public void run()
+ public void actionPerformed(ActionEvent e)
{
JobStateSummary jstate = new JobStateSummary();
for (final AWsJob job : jobs)
updateGlobalStatus(jstate);
if (jobComplete)
{
+ timer.stop();
// jobs should never be null at this point
parseResult(); // tidy up and make results available to user
- timer.cancel();
+
}
}
- };
- timer.schedule(task, 0, 5000);
+ });
+ timer.setInitialDelay(0);
+ timer.start();
}
protected void updateGlobalStatus(JobStateSummary jstate)
public void interrupt()
{
- timer.cancel();
+ timer.stop();
}
/**