Re: Java Timer



On 29 Nov 2005 19:45:39 -0800, "sconeek" <sconeek@xxxxxxxxx> wrote,
quoted or indirectly quoted someone who said :

>I am writing a Java app, where I need to wait for 10 seconds after a
>condition holds good and then check if the same condition still holds
>true and if yes then do something.
>
>Essentially I have this,
> if (mDt.getTime() == lsEtTSt.getTime()) {
> // wait for 10 seconds
>
> // check for the condition again
>
> // Do something
> }
>
>I dont want to use Thread.sleep. If somebody could suggest a loop or
>something which goes on for 10seconds that would be really great.

why not sleep? if you have only one test.

The alternative is to use a Timer that get triggered every 10 seconds.
The advantage here is you can use the same Timer thread to manage
several different periodic tests. See
http://mindprod.com/jgloss/timer.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.



Relevant Pages

  • How do I call a system (shell) app ?
    ... I'm writing a Java app that needs to call a shell command. ... is to ufraw, which is available for Linux, Windows and Mac. ...
    (comp.lang.java.help)
  • Re: Observations from a Windows user
    ... Linux too. ... It annoyed me when I was writing a Java app and took care to integrate its look into whatever OS it was running on. ...
    (uk.comp.sys.mac)
  • Java Timer
    ... I am writing a Java app, where I need to wait for 10 seconds after a ... If somebody could suggest a loop or ... Prev by Date: ...
    (comp.lang.java.programmer)