To be perfectly correct this should be a compare and swap in a loop, since l.lockCount might have changed since we checked it. Every time the compare and swap fails, l.lockCount needs to be checked again.

As it is, it will be possible to go a little beyond the limit or to be limited too early, depending on what else is happening.