Fix bug DNN-4029: when insert hashtable into cache, use double check to make sure it will not overwrite between threads, also use a thread safe version of the hash table.