Question: The AtomicInteger class ( in the java.util.concurrent.atomic package ) is a container for an integer value. One of its methods is boolean compareAndSet ( int

The AtomicInteger class (in the java.util.concurrent.atomic package) is a container for an integer value. One of its methods is boolean compareAndSet(int expect, int update). This method compares the objects current value with expect. If the values are equal, then it atomically replaces the objects value with update and returns true. Otherwise, it leaves the objects value unchanged, and returns false. This class also provides int get() which returns the objects value. Consider the FIFO queue implementation shown in Fig. 3.13. It stores its items in an array items, which, for simplicity, we assume has unbounded size. It has two AtomicInteger fields: head is the index of the next slot from which to remove an item, and tail is the index of the next slot in which to place an item. Give an example showing that this implementation is not linearizable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!