Locking

Adding locking to support multiple scheduler processes.