I don't fully understand the purpose of this mutex value, but I tend to think we should do the `k+1` inside of the mutex, otherwise we can have two concurrent code colliding and one `+1` will be ignored.
Can you add a comment explaining the goal of this mutex?