I've been thinking about implementing postDelay() in my game animation to make it more smooth. What I am worried about is that postDelay() creates a new Runnable everytime it is executed. Since my game needs postDelay() to be executed very often, will this create a lot of garbage since it is creating a new Runnable every time? Or even if it does not, does the creation of a new Runnable slow down performance?
So in this case, is it appropriate to use postDelay() in a situation where it is going to be executed very often for a long time?
You can use single
Runnableinstance for allpostDelayedcalls.But I think that a loop is better for games, it's a standard pattern, like in this post: How to appear and disappear an object on screen using game loop for every five second