Surround locks with WITH_THREADS