@synchronized vs. NSLock Instance vs. pthread_mutex_t

cocoa-touch, ios, multithreading, objective-c

Solution

It's important to keep in mind that `@synchronized` includes the necessary try/catch logic to release the lock in an exception. Once you add that logic the performance difference (which is not great in overall magnitude) will probably diminish significantly.

Problem

I was watching a (2-year old) tutorial video on multithreading that stated that - NSLock instance is 3x faster than using @synchronized - pthread_mutex_t is 2x faster than an NSLock instance (effectively 6x faster than @synchronized) Is this true? I haven't found anything that states with authority that it is, but I just wanted to poll some of you over at StackOverflow for your opinion and maybe solid proof. Thanks! While I've already accepted the correct answer, future viewers of this question will find this article to be helpful: http://perpendiculo.us/?p=133

Original source