4.6 Libgdx thread introduction, 4.6libgdx thread

Source: Internet
Author: User

4.6 Libgdx thread introduction, 4.6libgdx thread
All ApplicationListener methods are called in the same thread. This thread is a rendering thread that can call OpenGL. For most games, the update logic or rendering are generally placed in the ApplicationListener. render () method.
Any image operation will be performed in the rendering thread, and creation in other threads will lead to undefined behavior, Because OpenGL context is only available in the rendering process.
To transfer data from other threads to the rendering process, we recommend that you use Application. postRunnable (). This will enable the code to run at the next frame of the rendering process, before ApplicationListener. render () is called. New Thread (new Runnable (){
@ Override
Public void run (){
// Synchronize the required operations to the rendering thread.
Final Result result = createResult ();
// Push Runnable to the rendering thread.
Gdx. app. postRunnable (new Runnable (){
@ Override
Public void run (){
// Generate results
Results. add (result );
}
});
}
}). Start (); which Libgdx class is thread-safe?
In Libgdx, no class is thread-safe. Unless indicated in the official API. Remember, do not use multiple threads for any operations related to graphics and audio.
(Www.libgdx.cn is copyrighted. If you need to reprint it, indicate the source)


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.