Author discusses a Rust library, loom, used for testing lock-free data structures, sharing insights from accidentally implementing a similar toy program. The goal is not to teach practical use, but to derive unique ideas. A broken concurrent counter example is provided, with a trivial test failing due to timing issues. Property-based testing is suggested, with challenges in applying it to threads. The author proposes a method of pausing threads for controlled testing, leading to the implementation of managed threads with pause and unpause functions. The shared context between threads coordinates pausing, ensuring deterministic testing without unmanaged concurrency.
https://matklad.github.io/2024/07/05/properly-testing-concurrent-data-structures.html