std::cout<<"Final value of shared_resource: "<< shared_resource << std::endl; return0; }
输出结果:
Incremented shared_resource to 1(count =3)Incremented shared_resource to 2(count =2)Incremented shared_resource to 3(count =1)Incremented shared_resource to 4(count =0)Incremented shared_resource to 5(count =3)Incremented shared_resource to 6(count =2)Incremented shared_resource to 7(count =1)Incremented shared_resource to 8(count =0)Final value of shared_resource:8