首页 > 其他分享 >Leetcode多线程

Leetcode多线程

时间:2022-11-22 13:32:58浏览次数:60  
标签:function lock void unlock m3 m2 多线程 Leetcode


1114. 按序打印

​原题链接​

Leetcode多线程_按序

class Foo {
public:
Foo() {
m2.lock();
m3.lock();

}

void first(function<void()> printFirst) {
printFirst();
m2.unlock();
}

void second(function<void()> printSecond) {
m2.lock();
printSecond();
m3.unlock();
}

void third(function<void()> printThird) {
m3.lock();
printThird();
m3.unlock();
}

private:
std::mutex m2, m3;

};


标签:function,lock,void,unlock,m3,m2,多线程,Leetcode
From: https://blog.51cto.com/u_13875041/5877867

相关文章