(Original: Http://www.libgdx.cn/topic/48/4-6-libgdx%E7%BA%BF%E7%A8%8B%E4%BB%8B%E7%BB%8D) 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 () {
//this 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 () {
//result
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.
(www.libgdx.cn All rights reserved, if need to reprint, indicate source)
4.6, LIBGDX thread Introduction