Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After tinkering a bit with cocos2d, I discovered that there is no classic game loop and everything is more-or-less event driven. I guess I can wrap my head around that, no problem.

But I cannot find anything about thread safety. Say, I schedule something to occur every two seconds, which Thread will run the code? Given that I cannot find anything about that, I guess there is just one Cocos2d Thread and everything will be fine.

Nevertheless, this implicit assumption does not give me a good feeling. Knowing is better than guessing. ;-)

Can anyone shed some light onto that topic?

share|improve this question

as much as I can remember, there is no built-in threads in cocos2d. as you said everything is event driven but, events are queued, and run once at a time. so you don't need to worry about the thread safety at all, just keep in mind that some when you schedule two different events, they might not be run in same order as you scheduled them. but I think the priority option will solve that issue events with lower priority runs first.

share|improve this answer
This is what I assumed, but is there any documentation about that? Thanks for you answer, tho! :) – Malax Apr 13 '12 at 10:01
just imagine if cocos2d itself was using threads, why should they tell developers to use external pthread to do their threading needs? – Ali.S Apr 13 '12 at 10:05
Don't get me wrong, I think you're totally right. :-) I just would love to have a clear statement in the documentation about this. :-) – Malax Apr 13 '12 at 11:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.