Lock in appropriate places without deadlocking the app.