我有这样的代码:
final SwingWorker worker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {...};
}
Timer timer=new Timer(10000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
worker.execute();
}
});
timer.start();
有时worker进程需要超过10秒,但有时3-4秒,那么如何设置定时器等待worker完全执行?有什么建议么?