     }
 
     func unsubscribe(observable: DelayedObservableType) {
+        lock.lock(); defer { lock.unlock() }
         // Find index of observable which should be unsubscribed
         // and remove it from queue
         if let index = queue.index(where: { $0 === observable }) {

    /// into empty queue it's subscribed immediately. Otherwise
    /// it waits for completion from other observables.
    func queueSubscription(observable: DelayedObservableType) {
        let execute = queue.isEmpty
        queue.append(observable)
        if execute {


/// Queue which is used for queueing subscriptions for queueSubscribeOn operator.
class SerializedSubscriptionQueue {
    let lock = NSLock()

    /// First element on queue is curently subscribed and not completed
    /// observable. All others are queued for subscription when the first
    /// one is finished.
