CCLabelTTF : will become a white rectangle when I call setString method from a thread

any one can tell me why.

I tested it on 0.11 and 0.12

You can not invoke any cocos2d-x function or from a thread.
It is not thread-safe.

I am working on a network game using cocos2dx with libcurl.

I created a CCLabelTTF on a CCLayer object.

Then I made a thread to request my php server using curl.

when a get response from the thread, I want to print a string on the CCLabelTTF.

I call setString , finally it become a white rectangle.

And I found that will only happen when I call it from a thread.

Thank you! it seems like i have to find another way to make it done.

every thread has its own openGL context
if you add a texture in a thread which is not cocos2d-x’s GLThread,
cocos2d-x won’t get that texture because that texture belongs another thread.