         private var isPreviewForGIFGenerated = false
         private var scale: CGFloat?
         private var thumbnail: ImageRequest.ThumbnailOptions?
+        private let lock = NSLock()
+
+        public var isAsynchronous: Bool { thumbnail != nil }
 
         public init() { }
-
-        public var isAsynchronous: Bool { thumbnail != nil }
 
         /// Returns `nil` if progressive decoding is not allowed for the given
         /// content.

        }

        public func decode(_ data: Data) throws -> ImageContainer {
            func makeImage() -> PlatformImage? {
                if let thumbnail = self.thumbnail {
                    return makeThumbnail(data: data, options: thumbnail)

        }

        public func decodePartiallyDownloadedData(_ data: Data) -> ImageContainer? {
            lock.lock()
            defer { lock.unlock() }

            let assetType = AssetType(data)
            if assetType == .gif { // Special handling for GIF
                if !isPreviewForGIFGenerated, let image = ImageDecoders.Default._decode(data, scale: scale) {
