Add lock for preventing concurrent tasks loading