Reasoning behind locking threads