Ville Laakso wrote:

> How can I make something happen, say, every 5 seconds?
>
> -Ville Laakso
>  [EMAIL PROTECTED]

At least two ways:

Either call Thread.sleep (5000) or, if you have other things to do,

GregorianCalendar timeout=null, timenow=null ;
timeout = new GregorianCalendar () ;
timeout.add (GregorianCalendar.SECOND, 5) ;
while (true) {
  timenow = new GregorianCalendar () ;
  if (timenow.after (timeout)) {
    ... do whatever ...
    timeout = new GregorianCalendar () ;
    timeout.add (GregorianCalendar.SECOND, 5) ;
  }
... do other stuff ...
}

Peter
[EMAIL PROTECTED]



Reply via email to