Convert the locks to support a semaphore or mutex.