@synchronized vs NSLock Instance vs. pthread_mutex_t

I watched a (2 year) multithreading instructional video that said that

  • NSLock instance runs 3 times faster than using @synchronized
  • pthread_mutex_t is 2 times faster than an NSLock instance (effectively 6 times faster than @synchronized )

It's true? I did not find anything that claims with the authorities that this is so, but I just wanted to interview some of you at StackOverflow for your opinion and, maybe, solid evidence.

Thanks!

Although I already accepted the correct answer, future viewers of this question will find this article useful: http://perpendiculo.us/?p=133

+8
multithreading ios objective-c cocoa-touch
source share
1 answer

It is important to remember that @synchronized includes the necessary try / catch logic to release the lock in the exception. Once you add this logic, the difference in performance (which is small in total) is likely to decrease significantly.

+12
source share

All Articles