Repeat a task with a time delay?

I have a variable in my code say it is “status”.

I want to display some text in the application depending on this variable value. This has to be done with a specific time delay.

It’s like,

  • Check status variable value

  • Display some text

  • Wait for 10 seconds

  • Check status variable value

  • Display some text

  • Wait for 15 seconds

and so on. The time delay may vary and it is set once the text is displayed.

I have tried Thread.sleep(time delay) and it failed. Any better way to get this done?

12 Answers
12

Leave a Comment