I would like to do an operation every 100ms for 1000ms.
I believe I would need to use the
handler
How do I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This schedules a timer to execute a
TimerTask, with a 0 millisecond delay. It will execute the body of theTimerTaskevery 100 milliseconds. Usingcountto keep track of where you are in the task, after 10 iterations, you may cancel the timer.As @Jug6ernaut mentioned, ensure your task won’t take long to execute. Lengthy tasks (ones that take longer than 100 milliseconds, in your case) will cause lag/potentially undesirable results.