One thing to watch out for in C++ is the Data Race. Because threads share the same memory, if two threads try to change the same variable at the same time, there will be Undefined Behavior.
we can use std::mutex to lock the data while a thread is using it.