implementation of the naive lock