How do you use a TimerTask to run a thread?

后端 未结 3 1106
执念已碎
执念已碎 2020-11-29 06:37

I\'m struggling to find documentation for the TimerTask function on Android. I need to run a thread at intervals using a TimerTask but have no idea how to go about this. Any

3条回答
  •  感情败类
    2020-11-29 07:10

    This is perfect example for timer task.

    Timer timerObj = new Timer();
    TimerTask timerTaskObj = new TimerTask() {
        public void run() {
           //perform your action here
        }
    };
    timerObj.schedule(timerTaskObj, 0, 15000);
    

提交回复
热议问题