Reputation: 352
The Android must manage the thread or can be used a code like this:
public class GameThread implements Runnable {
public void run() {
while (!finished) {
//game work
try {
Thread.sleep(fps);
} catch (InterruptedException e) {
// Interruptions here are no big deal.
}
}
}
}
Upvotes: 3
Views: 99
Reputation: 41975
You can use the Thread
directly but there are some catches in Android
Android documentation on Processes and Threads provides ample guidelines to help you get started.
AsyncTask allows you to perform asynchronous work on your user interface. It performs the blocking operations in a worker thread and then publishes the results on the UI thread, without requiring you to handle threads and/or handlers yourself.
Upvotes: 5
Reputation: 1186
Android has its own Threading model and framework, which is much more sophisticated than plain Java. The documentation explains everything you need.
Upvotes: 4