This implementation is not thread safe! and so iterator can't behave correctly. There are 2 two possible data races. You should use non blocking spin-based algorithm.