Skip to content
Advertisement

Usecase of using AtomicStampedReference & AtomicMarkableReference

I am looking for a example of AtomicStampedReference and/or AtomicMarkableReference, that could help me understand these classes and their functions.

I am not able to get any quality examples over the web.

I can think of using these in garbage collection, but a quality example will help me understand these better.

Advertisement

Answer

Practical examples (Complicated)

For AtomicMarkableReference:

https://github.com/arunmoezhi/ConcurrentKaryST

For AtomicStampedReference

https://github.com/arunmoezhi/LockFreeBST

Simple example:

In a binary tree if you want to change a child of a parent node atomically, then compareAndSwap on an AtomicMarkableReference can be used.

In a binary tree lets say you want to flag a node atomically. Then AtomicStampedReference can be used.

The above complicated real life implementations use these two class types.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement