adding lock-free and lock-based implementations