#include #include using namespace std; int a = 0, b = 0; void suma() { while (true) { ++a; ++b; } } void resta() { while (true) { --a; --b; } } void muestra() { while (true) { cout << "a = " << a << "\t b = " << b << endl; this_thread::sleep_for(250ms); } } int main() { thread t[3] = {thread(suma), thread(resta), thread(muestra)}; for (auto &i: t) i.join(); }