                 waitUntil(timeout: 2.0) { done in
                     let queue = dispatch_queue_create("SwinjectTests.SynchronizedContainerSpec.Queue", DISPATCH_QUEUE_CONCURRENT)
                     let totalThreads = 500 // 500 threads are enough to get fail unless the container is thread safe.
-                    let counter = Counter()
+                    let counter = Counter(max: 2 * totalThreads)
                     for _ in 0..<totalThreads {
                         dispatch_async(queue) {
                             let parent = container.resolve(ParentType.self) as! Parent

    }
    
    final class Counter {
        private let lock = dispatch_queue_create("SwinjectTests.SynchronizedContainerSpec.Counter.Lock", nil)
        private var _count = 0
        
        var count: Int {
            var ret = 0
            dispatch_sync(lock) {
                ret = self._count
            }
            return ret
        }
        
        func increment() {
            dispatch_sync(lock) {
                self._count++
            }
        }
    }
}

                    waitUntil(timeout: 2.0) { done in
                        let queue = dispatch_queue_create("SwinjectTests.SynchronizedContainerSpec.Queue", DISPATCH_QUEUE_CONCURRENT)
                        let totalThreads = 500
                        let counter = Counter(max: 2 * totalThreads)
                        
                        for _ in 0..<totalThreads {
                            dispatch_async(queue) {
                                _ = parentResolver.resolve(AnimalType.self) as! Cat
                                if counter.increment() == .ReachedMax {
                                    done()
                                }
                            }
                            dispatch_async(queue) {
                                _ = childResolver.resolve(AnimalType.self) as! Cat
                                if counter.increment() == .ReachedMax {
                                    done()
                                }
                            }
                        }
                    }
