 import MapKit
 
 class ImageCache {
+
     static let sharedInstance = ImageCache()
 
     let cache = NSCache()
+    let cacheQueue = dispatch_queue_create("ImageCacheQueue", DISPATCH_QUEUE_CONCURRENT)
 
     func imageOfMessage(message: Message, withSize size: CGSize, tailDirection: MessageImageTailDirection, completion: (loadingProgress: Double, image: UIImage?) -> Void) {
 

                        } else {
                            // 或放个默认的图片
                            let defaultImage = tailDirection == .Left ? UIImage(named: "left_tail_image_bubble")! : UIImage(named: "right_tail_image_bubble")!
                            dispatch_async(dispatch_get_main_queue()) {
                                completion(loadingProgress: preloadingPropgress, image: defaultImage)
                            }

                completion(loadingProgress: preloadingPropgress, image: thumbnail)

            } else {
                dispatch_async(self.cacheQueue) {

                    if let message = messageWithMessageID(messageID, inRealm: Realm()) {
                        if let blurredThumbnailImage = blurredThumbnailImageOfMessage(message) {
                            let bubbleBlurredThumbnailImage = blurredThumbnailImage.bubbleImageWithTailDirection(tailDirection, size: size).decodedImage()
