当前位置: 首页 > news >正文

Leetcode—1114. 按序打印【简单】(多线程)

2024每日刷题(179)

Leetcode—1114. 按序打印

在这里插入图片描述

C++实现代码

class Foo {
public:Foo() {firstMutex.lock();secondMutex.lock();}void first(function<void()> printFirst) {// printFirst() outputs "first". Do not change or remove this line.printFirst();firstMutex.unlock();}void second(function<void()> printSecond) {// printSecond() outputs "second". Do not change or remove this line.firstMutex.lock();printSecond();secondMutex.unlock();}void third(function<void()> printThird) {// printThird() outputs "third". Do not change or remove this line.secondMutex.lock();printThird();}
private:mutex firstMutex;mutex secondMutex;
};

运行结果

在这里插入图片描述
之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!


http://www.mrgr.cn/news/56422.html

相关文章:

  • 中间件之MQ-Kafka
  • 前端算法:字典and哈希表(力扣1题、349题解法)
  • Flux.using 使用说明书
  • LinkedList和链表之刷题课(上)
  • 【机器视觉必学篇】线阵工业相机的原理及应用
  • 利用Pix4D和ArcGIS计算植被盖度
  • http作业
  • 10.22软考初级网络管理员工重点之因特网与网络互联技术
  • 红黑树(创建 插入 测试验证)
  • 深入了解Java
  • 力扣 困难 52.N皇后II
  • <a-table>行数据增加点击事件并获取点击行的数据+自定义button按事件
  • MySQL之CRUD(下)
  • 中间件之MQ-Kafka
  • sql数据库的命令行操作(修改表)
  • Leetcode—1242. 多线程网页爬虫【中等】Plus(多线程)
  • C语言初阶小练习4(不用临时变量交换数值)
  • dolphinscheduler创建工作流及工作流中DataX的使用(简单操作)
  • TikTok账号被限流怎么解决?
  • 【二】企业级JavaScript开发之代码编辑器
  • 什么是表单数据
  • 群晖通过 Docker 安装 Gitea
  • 两个线程交替打印数字
  • 鸿蒙开发:两个重磅更新,鸿蒙版微信要来了!
  • Java学习Day50:唤醒八戒(Excel相关)
  • 中间件之Seata