我想将 data() 方法更新为每 500 毫秒,但我下面的计时器更新 data() 方法超过 4 或 5 秒。谢谢..
class RemindTask extends TimerTask {
public void run() {
try {
data();
} catch (UnsupportedCommOperationException ex) {
Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
} catch (TooManyListenersException ex) {
Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
}
}
和定时器触发方法是..
private void okActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getSource()==ok)
{
bul=true;
if(new communication().bul1==false)
{
JOptionPane.showMessageDialog(test2,"GPS CONNECTE");
}
//System.out.print(bd.get);
timer = new Timer();
timer.schedule(new RemindTask(), 500);
}