Guys I need some help to architect my multithreading in iOS.
I’m using ARC in my code.
So basically I need following,
In my main thread nstimer fire some method which should be executed in a separate thread, that thread does some calculation and puts data into some ivar, and another thread should read data from that ivar and do some other calculation, i.e. if there is no data the second thread should wait until there is any.
So basically I would like to hear some advice which technology is the best choice for my task, to use cocoa thread (NSThread), GCD or Operation queues.
Also can someone please provide me with some pseudo code on aspects of mutual blocking/synchronization between two threads.
Unless you left something our of your problem description, that is a perfect fit for GCD/block combo. In fact, I wouldn’t even use a NSTimer (GCD provides a better alternative – see dispatch_source_create for example of creating GCD based timer), but that’s your call, and not what the question asked. Anyway, with GCD…