Use of threads
Why do I use threads for Android development games?
Some non-static resources in the game (such as flowing water) need to constantly refresh the canvas (canvas) to achieve the dynamic effect, which requires a timed refresh (even if there is no action), then a thread is required to constantly refresh the canvas to achieve the dynamic effect.
How do I use threads?
Single threaded uses the thread class to instantiate the thread class directly to get a threading object (but this method can only implement one thread object, because Java cannot inherit much, but this is more resource-efficient for programs that require only one thread). Another way is to implement the Runnable interface, which can implement multiple inheritance.
Thread specific use:
In the game to implement the thread's Run () method, often write a dead loop, so that the game logic method is constantly executing to achieve dynamic results. But at the same time, we can set a flag to determine the end condition of the loop, thus making the loop more convenient to control.
This article is from the "11713059" blog, please be sure to keep this source http://11723059.blog.51cto.com/11713059/1870072
Android Game Development Notes (i)