Added shared lock to the environment and modified task intances to take
advantage of them