Use synchronization to ensure only one thread can access the imap and/or the cache