Unskilled Unskilled - 2 months ago 7
Java Question

Java how to wait before going on

I want my runnable to wait a couple of seconds before starting again, any advice on how to do this?

if i use this.wait(); it doesn't work because that stops everthing in my program and i just want the runnable to pause.


Here is an example for 2 second delayed Runnable

final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
    public void run() {
        // Do stuff

        handler.postDelayed(this, 2000);

handler.postDelayed(runnable, 2000);