多线程代码:交叉打印,熟悉mutex、unique_lock、condition_variable
classFooBar{private:intn;intflag;mutexmut;condition_variablecond;public:FooBar(intn){this->n=n;flag=0;}voidfoo(functionprintFoo){for(inti=0;ilck(mut);cond.wait(lck,[this](){returnflag==0;});//printFoo