Using wait in AsyncTask

前端 未结 6 1531
逝去的感伤
逝去的感伤 2021-02-01 01:15

When using a wait in an AsyncTask, I get ERROR/AndroidRuntime(24230): Caused by: java.lang.IllegalMonitorStateException: object not locked by thr

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 01:53

    If you're looking to just postpone execution of a method for a set amount of time, a good option is Handler.postDelayed()

    define the handler and runnable...

    private Handler handler = new Handler();
    private Runnable runnable = new Runnable() {        
        finished();
    };
    

    and execute with delay...

    handler.postDelayed(runnable, MIN_SPLASH_DURATION);
    

提交回复
热议问题