Does Thread.sleep() makes the UI Thread to sleep?

后端 未结 4 959
逝去的感伤
逝去的感伤 2020-12-19 22:43

Will this make the current UI thread to sleep?

try 
{
   Thread.sleep(20);
   onProgressUpdate(i);
} catch (InterruptedException e) {
      e.printStackTrace         


        
4条回答
  •  鱼传尺愫
    2020-12-19 23:37

    Thread.sleep(time) will causes the thread which sent this message to sleep for the given interval of time. So if you call it in UI thread, it will affect the UI thread. As far as android is concerned it is not advised to obstruct UI thread in any way, otherwise it will result in ANR - application not responding.

    You can refer this

提交回复
热议问题