In this chapter, we introduced a rather simple example of designing a stack. There are more complex examples to research and follow. When we discussed designing a concurrent stack, we looked at two versions, one of them representing a lock-free stack. Compared to lock-based solutions, lock-free data structures and algorithms are the ultimate goal for programmers as they provide mechanisms to avoid data races without even synchronizing the resources.
We also introduced atomic types and operations that you can use in your projects to make sure instructions are indivisible. As you already know, if an instruction is atomic, there is no need to worry about its synchronization. We strongly suggest you continue researching the topic and build more robust and complex lock-free data structures. In the next chapter, we will see how to design world-ready applications.
...