From experience: this is a lot harder than it may look. On a tangent: does anyone here know of techniques or algorithms for verifying that a lock-free or obstruction-free algorithm works? Ideally some that can actually be applied in practice. So far I've been manually trying out all possible scheduling combinations, which is very tedious and can be error prone on larger algorithms. It's also not clear if doing the analysis for 2 concurrent threads automatically extends to 3 or more (it clearly does for some algorithms).<p>I've been thinking along the lines of a DSL for such algorithms that can compile down to whatever language you need, but also easily lends itself to static analysis for verification, but I feel my lack of classical CompSci training is letting me down here a bit.