gpt4 book ai didi

java - Objective-C 中是否允许嵌套同步块(synchronized block)?

转载 作者:IT老高 更新时间:2023-10-28 21:00:14 26 4
gpt4 key购买 nike

我阅读了 this article在 Java 中,允许嵌套同步块(synchronized block)。我知道 Objective-C 的同步块(synchronized block)看起来很像 Java 的。所以我想知道:Objective-C 中是否允许嵌套 block ?

我还有一个附带问题:递归 block 有实际限制吗?

感谢您的快速答复!

最佳答案

是的,他们是。来自 the docs (现已退休):

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.

有关此方法和其他同步/锁定方法的性能讨论,请参阅 here .

关于java - Objective-C 中是否允许嵌套同步块(synchronized block)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7052553/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com