Using mutex to synchronize the writes on the collections