How to “wait” a Thread in Android

前端 未结 5 1816
夕颜
夕颜 2020-12-30 18:18
private void startGameTimeElapseThread(){
    new Thread(new Runnable() {
        Date d = new Date();
        public void run() {
            while (gameOn){
               


        
5条回答
  •  执念已碎
    2020-12-30 19:20

    You need the sleep method of the Thread class.

    public static void sleep (long time)

    Causes the thread which sent this message to sleep for the given interval of time (given in milliseconds). The precision is not guaranteed - the Thread may sleep more or less than requested.

    Parameters

    time The time to sleep in milliseconds.

提交回复
热议问题