             return qualityOfService == .userInitiated
         }
         set {
+            stateAccess.lock()
+            defer { stateAccess.unlock() }
+            
             assert(state < .executing, "Cannot modify userInitiated after execution has begun.")
             qualityOfService = newValue ? .userInitiated : .default
         }

            return currentState
        }
        set {
            /*
             It's important to note that the KVO notifications are NOT called from inside
             the lock. If they were, the app would deadlock, because in the middle of

    }
    
    // MARK: Execution and Cancellation
    override final public func main() {
        stateAccess.lock()
        defer { stateAccess.unlock() }
        assert(state == .ready, "This operation must be performed on an operation queue.")
        
        if _internalErrors.isEmpty && !isCancelled {
