ABA在无锁算法中 [英] ABA in lock free algorithms

查看:134
本文介绍了ABA在无锁算法中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解 ABA 问题。但我无法理解的是:他们说在自动垃圾收集的语言中可能无法展示。所以我的问题是:

I understand the ABA problem. But the thing which I am unable to comprehend is: they say that in languages having automatic garbage collection it may not exhibit. So my questions are:


  • 自动垃圾收集如何防止发生ABA问题?

  • 是吗?可能在java中,如果是,如何?

  • 是否可以防止这种情况发生?

推荐答案


  • 当启用自动垃圾收集时,不能同时使用相同的引用分配两个对象并同时共存,这是因为只要引用计数更大那么0引用本身将不会被释放并重新使用。

    • When automatic garbage collection is enabled ,no two objects can be allocated with the same reference and co-exist at the same time,that's because as long as there is a reference count greater then 0 the reference itself will not be released and re-used.

      所以你不能将参考内容切换为不同对象的点,而有人仍然拥有旧参考。

      so you cannot "switch" the reference contents to "point" for different object while someone still has the old reference.

      这篇关于ABA在无锁算法中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆