         let key = ContainerItemKey(factoryType: factory.dynamicType, name: name)
         let entry = ContainerEntry(serviceType: serviceType, factory: factory)
 
-        services[key] = entry
+        // ensure no other access while writing
+        dispatch_barrier_sync(accessQueue) {
+            services[key] = entry
+        }
 
         return entry
     }


    private var services = [ContainerItemKey: ContainerItemType]()

    public func register<T>(serviceType: T.Type, name: String? = nil, factory: Resolvable -> T) -> ContainerEntry<T> {
        return registerFactory(serviceType, factory: factory, name: name)
    }

    internal func resolveFactory<T, Factory>(name: String?, invoker: Factory -> T) -> T? {
        let key = ContainerItemKey(factoryType: Factory.self, name: name)

        var lockedEntry: ContainerItemType? = nil

        // read from data structure in a thread-safe manner
        dispatch_sync(accessQueue) {
            lockedEntry = services[key]
        }

        if let entry = lockedEntry as? ContainerEntry<T> {
            if entry.instance == nil {
                entry.instance = resolveEntry(entry, key: key, invoker: invoker) as Any
            }
