     // create session and instance of API for each subclasses
     private final class var instancePair: (API, NSURLSession) {
         let className = NSStringFromClass(self)
+        
+        dispatch_semaphore_wait(instancePairSemaphore, DISPATCH_TIME_FOREVER)
         let pair: (API, NSURLSession) = instancePairDictionary[className] ?? {
             let instance = self.init()
             let configuration = self.URLSessionConfiguration()


// use private, global scope variable until we can use stored class var in Swift 1.2
private var instancePairDictionary = [String: (API, NSURLSession)]()

public class API: NSObject, NSURLSessionDelegate {
    // configurations

            instancePairDictionary[className] = pair
            return pair
        }()
        dispatch_semaphore_signal(instancePairSemaphore)
        
        return pair
    }
