 class DefaultDatafileHandler : OPTDatafileHandler {
     static public var endPointStringFormat = "https://cdn.optimizely.com/datafiles/%@.json"
     lazy var logger = HandlerRegistryService.shared.injectLogger()
-    var timers:[String:Timer] = [String:Timer]()
+    var timers:AtomicProperty<[String:Timer]> = AtomicProperty(property: [String:Timer]())
     let dataStore = DataStoreUserDefaults()
     
     required init() {

    }
    
    func stopPeriodicUpdates(sdkKey: String) {
        if let timer = timers[sdkKey] {
            logger?.log(level: .info, message: "Stopping timer for datafile updates sdkKey:" + sdkKey)
            
            timer.invalidate()
            timers.removeValue(forKey: sdkKey)
        }

    }
    
    func stopPeriodicUpdates() {
        for key in timers.keys {
            logger?.log(level: .info, message: "Stopping timer for all datafile updates")
            stopPeriodicUpdates(sdkKey: key)
        }
        
    }

    }
    
    func startPeriodicUpdates(sdkKey: String, updateInterval: Int, datafileChangeNotification:((Data)->Void)?) {
        
        timers.performAtomic { (timers) in
            if let timer = timers[sdkKey] {
                logger?.log(level: .info, message: "Timer getting restarted for datafile updates \(sdkKey)")
                timer.invalidate()
                timers[sdkKey] = nil
                //return
            }
        }
        if #available(iOS 10.0, tvOS 10.0, *) {
            DispatchQueue.main.async {
                let timer = Timer.scheduledTimer(withTimeInterval: TimeInterval(updateInterval), repeats: false) { (timer) in
                    
                    self.downloadDatafile(sdkKey: sdkKey, completionHandler: { (result) in
                        switch result {
                        case .success(let data):
                            if let data = data,
                                let datafileChangeNotification = datafileChangeNotification {
                                datafileChangeNotification(data)
                            }
                        case .failure(let error):
                            self.logger?.log(level: .error, message: error.localizedDescription)
                        }
                        self.startPeriodicUpdates(sdkKey: sdkKey, updateInterval: updateInterval, datafileChangeNotification: datafileChangeNotification)
                    })
                }
                self.timers.performAtomic(atomicOperation: { (timers) in
                    timers[sdkKey] = timer
                })
            }
        } else {
            // Fallback on earlier versions
