线程通讯通过全局promise变量和线程局部变量future进行通讯。
promise<string> val;//全局通讯变量
int main(){
thread th1([](){
future<string> fus = val.get_future();//获取未来状态
cout<<"等待中…"<<endl;
cout<<fus.get()<<endl;
});
thread th2([](){
system("pause");
val.set_value("hello cpp");
});
th1.join();
th2.join();
return 1;
}