It’s important to protect shared data in multi-threading application. Locking could be expensive. Consider to use a lock free data structure.