I read in this article that in Java, nested synchronised blocks are allowed. I know that Objective-C's synchronised blocks look a lot like Java's. So I wonder: Are nested blocks allowed in Objective-C?
I also have a side question: Is there a practical limit on recursive blocks?
Thank you for your speedy answer!
Yes, they are. From the docs (now retired):
The Objective-C synchronization feature supports recursive and reentrant code. A thread can use a single semaphore several times in a recursive manner; other threads are blocked from using it until the thread releases all the locks obtained with it; that is, every @synchronized() block is exited normally or through an exception.
For a discussion of performance with this and other methods of synchronization/locking, see here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With