My app has many threads
, so I do get lot of crashes when the same variable is updated and read at the same time.
To solve this issue I decided to use NSLock and lock it when the variables are updated and similarly lock it when I get an event Ex: tapping , scrolling the table view. When getting an event I am locking the NSLock so variables are not updated, when the app is idle(no events) I am updating the variables.
My question how can I come to know whether run loop has any events to be executed and similarly how can i know whether event is handled or not so that I can lock and unlock the NSLock respectivelty.