#include <iostream>
#include <thread>
//thread_local int var;
//int var;
class A{
public:
void fun () {
for(int i=0; i<10; i++){
var = var+i;
}
std::cout<<"var = "<<var<<std::endl;
}
};
int main() {
A a, b, c;
std::thread t1(&A::fun, &a);
std::thread t2(&A::fun, &b);
std::thread t3(&A::fun, &c);
t1.join();
t2.join();
t3.join();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: