在Java中以原子方式释放多个锁 [英] Release multiple locks atomically in Java
本文介绍了在Java中以原子方式释放多个锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我已经获得了许多锁,我该如何自动释放锁组?
If I have acquired a number of locks, how do I release the Set of locks atomically?
推荐答案
As locks are treated as independend objects (see this question) and the Java language does not (yet, as of my knowledge) provide a method in its JVM (where it would have to be implemented to be really atomically) to release multiple locks in one step, it is simply not possible.
也许可以重新设计您的应用程序,从而不再需要几个锁的原子释放. (也许您还可以提供有关您的特定问题的更多详细信息,以便我们更好地理解)
Maybe it is possible to redesign your application so that an atomic release of several locks is not needed anymore. (Maybe you could also give more details on your specific problem that we can get a better understanding)
这篇关于在Java中以原子方式释放多个锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文