-
Notifications
You must be signed in to change notification settings - Fork 10
[3.0] Threadings
There are 3 kind of threads in Meganekko.
- Main thread: This is created by Android system. It is often called as UI thread.
- GL thread: This is created by Meganekko. All GL related process must be done in this thread.
- Background thread: This is created by user (or other libraries).
You should not block Main thread or GL thread. If you want to do something that takes long time, it is recommended to create new thread and call back result with MeganekkoApp.runOnGlThread
or MeganekkoApp.runOnUiThread
.
Some methods must be called from Main thread. Especially Android system operations. You can run your code in Main thread with MeganekkoApp.runOnUiThread
.
Some methods must be called from GL thread. For example, MeganekkoApp.setScene
, create SurfaceRendererComponent
, GeometryComponent
, and other GL related operations. You can run your code in GL thread with MeganekkoApp.runOnGlThread
.
Background thread is created by some methods. For example ExecutorService
, AsyncTask
, Timer
, new Thread() {}
. Using ExecutorService
is recommended way.