Skip to content
This repository has been archived by the owner on Dec 26, 2018. It is now read-only.

[3.0] Threadings

Yuya Matsuo edited this page Sep 13, 2016 · 2 revisions

There are 3 kind of threads in Meganekko.

  1. Main thread: This is created by Android system. It is often called as UI thread.
  2. GL thread: This is created by Meganekko. All GL related process must be done in this thread.
  3. 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.

Clone this wiki locally