iPhone "multi-threading" question

Posted by MrDatabase on Stack Overflow See other posts from Stack Overflow or by MrDatabase
Published on 2010-05-09T06:24:42Z Indexed on 2010/05/09 6:28 UTC
Read the original article Hit count: 172

I have a simple iPhone game consisting of two "threads": the main game loop where all updating and rendering happen 30 times per second (NSTimer)... and the "thread" that calls the accelerometer delegate 100 times per second. I have a variable "xPosition" that's updated in the accelerometer delegate function and used in the game loop. Is there a possibility of the two "threads" trying to use xPosition at the same time (hence causing a crash or some other problem). If so how can I fix this w/ minimal impact to the game's performance?

I've been using this set-up for many months of development and incremental testing and I've never run into any problems.

Cheers!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about accelerometer