An Introduction to C++ Concurrency with LeetCode 1114

An Introduction to C++ Concurrency with LeetCode 1114 Originally published in Chinese on 2020-09-30; this English edition preserves the original scope and technical context. Problem Directly solve the problem: 1114 Print in Order Solution 1. std::mutex If you are somewhat familiar with C++ 11, you might think of using std::mutex to solve this problem. In the constructor of the function (main thread), lock the std::mutex, and then unlock the std::mutex object in each thread’s function: ...

September 30, 2020 · 6 min · Zhengyu Chen