Added the code for a thread-safe data structure