It is not thread-safe.
To get synchronized behaviour without using blocking (mutexes) you could e.g. use the C++11 wrapper std::atomic
.
std::atomic<int> a{5};
void work() {
a += 5; // Performed atomically.
}
int main() {
std::thread t1{work};
std::thread t2{work};
t1.join();
t2.join();
std::cout << a << std::endl; // Will always output 15.
}