All Applicationlistener methods are called in the same thread. This thread is a render thread that can invoke OpenGL. For most games, the update logic or rendering is generally placed in the Applicationlistener.render () method.
Any image manipulation is done in the render thread, and being contrived in other threads leads to undefined behavior because OpenGL context is only available in the rendering process.
In order to pass data from other threads into the rendering process, we recommend the use of application.postrunnable (). This will cause the code to run in the next frame of the rendering process, and before Applicationlistener.render () is called. new Thread (New Runnable () {
@Override
public void Run () {
//completes the desired operation, synchronizing to the render thread.
final result result = Createresult ();
//pushes runnable to the render thread.
gdx.app.postrunnable (New Runnable () {
@ OVERRIDE
public void Run () {
//produces results
results.add (result);
}
});
}
}). Start (); Is that LIBGDX class thread-safe?
In Libgdx, no class is thread-safe. Unless indicated in the official API. Remember, do not use multithreading for any graphics and audio related operations.
4.6, LIBGDX thread Introduction