4.6, LIBGDX thread Introduction

Source: Internet
Author: User
Tags libgdx

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.