{"id":66597,"date":"2026-01-26T23:41:10","date_gmt":"2026-01-26T15:41:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/66597.html"},"modified":"2026-01-26T23:41:10","modified_gmt":"2026-01-26T15:41:10","slug":"c11%e6%9d%a1%e4%bb%b6%e5%8f%98%e9%87%8f%ef%bc%9a%e7%ba%bf%e7%a8%8b%e5%90%8c%e6%ad%a5%e6%a0%b8%e5%bf%83%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/66597.html","title":{"rendered":"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7"},"content":{"rendered":"<p>\u597d\u7684&#xff0c;\u6211\u4eec\u6765\u8be6\u7ec6\u63a2\u8ba8C&#043;&#043;11\u6807\u51c6\u5e93\u4e2d\u7684std::condition_variable&#xff08;\u6761\u4ef6\u53d8\u91cf&#xff09;\u3002<\/p>\n<h4>&#x1f9e9; \u4e00\u3001\u6761\u4ef6\u53d8\u91cf\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<p>std::condition_variable \u662fC&#043;&#043;11\u5f15\u5165\u7684\u7ebf\u7a0b\u540c\u6b65\u539f\u8bed&#xff0c;\u7528\u4e8e\u5b9e\u73b0\u7ebf\u7a0b\u95f4\u7684\u7b49\u5f85\/\u901a\u77e5\u673a\u5236\u3002\u5b83\u5141\u8bb8\u4e00\u4e2a\u6216\u591a\u4e2a\u7ebf\u7a0b\u963b\u585e\u7b49\u5f85&#xff0c;\u76f4\u5230\u88ab\u5176\u4ed6\u7ebf\u7a0b\u901a\u77e5\u67d0\u4e2a\u6761\u4ef6\u6210\u7acb&#xff08;\u6216\u8d85\u65f6&#xff09;\u3002\u5b83\u901a\u5e38\u4e0estd::mutex\u548cstd::unique_lock\u914d\u5408\u4f7f\u7528\u3002<\/p>\n<h4>&#x1f511; \u4e8c\u3001\u6838\u5fc3\u65b9\u6cd5<\/h4>\n<li>\n<p>wait(unique_lock&lt;mutex&gt;&amp; lock)<\/p>\n<ul>\n<li>\u5f53\u524d\u7ebf\u7a0b\u963b\u585e&#xff0c;\u76f4\u5230\u88abnotify_one()\u6216notify_all()\u5524\u9192\u3002<\/li>\n<li>\u5728\u963b\u585e\u524d&#xff0c;\u4f1a\u81ea\u52a8\u91ca\u653e\u4f20\u5165\u7684\u9501lock\u3002<\/li>\n<li>\u88ab\u5524\u9192\u540e&#xff0c;\u5728\u8fd4\u56de\u524d\u4f1a\u91cd\u65b0\u83b7\u53d6\u9501lock\u3002<\/li>\n<li>\u5b58\u5728\u865a\u5047\u5524\u9192\u7684\u53ef\u80fd&#xff08;\u5373\u4f7f\u672a\u88ab\u901a\u77e5\u4e5f\u53ef\u80fd\u5524\u9192&#xff09;&#xff0c;\u56e0\u6b64\u901a\u5e38\u9700\u8981\u5728\u5faa\u73af\u4e2d\u68c0\u67e5\u6761\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>wait(unique_lock&lt;mutex&gt;&amp; lock, Predicate pred)<\/p>\n<ul>\n<li>\u5e26\u8c13\u8bcd&#xff08;Predicate&#xff09;\u7684\u91cd\u8f7d\u7248\u672c\u3002<\/li>\n<li>\u7b49\u4ef7\u4e8e&#xff1a;\n<p>while (!pred()) {<br \/>\n    wait(lock);<br \/>\n}<\/p>\n<\/li>\n<li>\u80fd\u81ea\u52a8\u5904\u7406\u865a\u5047\u5524\u9192&#xff0c;\u63a8\u8350\u4f7f\u7528\u6b64\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>notify_one()<\/p>\n<ul>\n<li>\u5524\u9192\u4e00\u4e2a\u6b63\u5728\u7b49\u5f85\u6b64\u6761\u4ef6\u53d8\u91cf\u7684\u7ebf\u7a0b&#xff08;\u5982\u679c\u6709\u591a\u4e2a\u5728\u7b49\u5f85&#xff0c;\u5177\u4f53\u5524\u9192\u54ea\u4e2a\u4e0d\u786e\u5b9a&#xff09;\u3002<\/li>\n<li>\u901a\u5e38\u7528\u4e8e\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u80fd\u5904\u7406\u88ab\u6ee1\u8db3\u7684\u6761\u4ef6\u65f6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>notify_all()<\/p>\n<ul>\n<li>\u5524\u9192\u6240\u6709\u6b63\u5728\u7b49\u5f85\u6b64\u6761\u4ef6\u53d8\u91cf\u7684\u7ebf\u7a0b\u3002<\/li>\n<li>\u901a\u5e38\u7528\u4e8e\u591a\u4e2a\u7ebf\u7a0b\u90fd\u80fd\u5904\u7406\u88ab\u6ee1\u8db3\u7684\u6761\u4ef6\u65f6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>wait_for \/ wait_until<\/p>\n<ul>\n<li>\u5e26\u8d85\u65f6\u529f\u80fd\u7684\u7b49\u5f85\u3002\u5141\u8bb8\u7ebf\u7a0b\u5728\u6307\u5b9a\u65f6\u95f4\u6bb5\u5185\u6216\u88ab\u901a\u77e5\u65f6\u5524\u9192&#xff0c;\u907f\u514d\u6c38\u4e45\u963b\u585e\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>&#x1f9e0; \u4e09\u3001\u4f7f\u7528\u6a21\u5f0f&#xff08;\u751f\u4ea7\u8005-\u6d88\u8d39\u8005\u793a\u4f8b&#xff09;<\/h4>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;thread&gt;<br \/>\n#include &lt;mutex&gt;<br \/>\n#include &lt;condition_variable&gt;<br \/>\n#include &lt;queue&gt;<\/p>\n<p>std::mutex mtx;<br \/>\nstd::condition_variable cv;<br \/>\nstd::queue&lt;int&gt; data_queue;<br \/>\nbool done &#061; false; \/\/ \u6807\u8bb0\u662f\u5426\u6240\u6709\u6570\u636e\u751f\u4ea7\u5b8c\u6bd5<\/p>\n<p>\/\/ \u751f\u4ea7\u8005\u7ebf\u7a0b<br \/>\nvoid producer() {<br \/>\n    for (int i &#061; 0; i &lt; 10; &#043;&#043;i) {<br \/>\n        {<br \/>\n            std::lock_guard&lt;std::mutex&gt; lk(mtx);<br \/>\n            data_queue.push(i);<br \/>\n            std::cout &lt;&lt; &#034;Produced: &#034; &lt;&lt; i &lt;&lt; std::endl;<br \/>\n        } \/\/ lock_guard \u79bb\u5f00\u4f5c\u7528\u57df\u81ea\u52a8\u89e3\u9501<br \/>\n        cv.notify_one(); \/\/ \u901a\u77e5\u4e00\u4e2a\u6d88\u8d39\u8005<br \/>\n    }<br \/>\n    {<br \/>\n        std::lock_guard&lt;std::mutex&gt; lk(mtx);<br \/>\n        done &#061; true; \/\/ \u8bbe\u7f6e\u751f\u4ea7\u5b8c\u6210\u6807\u5fd7<br \/>\n    }<br \/>\n    cv.notify_all(); \/\/ \u901a\u77e5\u6240\u6709\u6d88\u8d39\u8005\u53ef\u80fd\u7ed3\u675f<br \/>\n}<\/p>\n<p>\/\/ \u6d88\u8d39\u8005\u7ebf\u7a0b<br \/>\nvoid consumer() {<br \/>\n    while (true) {<br \/>\n        std::unique_lock&lt;std::mutex&gt; lk(mtx); \/\/ \u5fc5\u987b\u7528 unique_lock&#xff0c;\u56e0\u4e3a wait \u4f1a\u89e3\u9501<br \/>\n        \/\/ \u7b49\u5f85\u6761\u4ef6&#xff1a;\u961f\u5217\u4e0d\u4e3a\u7a7a \u6216 \u751f\u4ea7\u8005\u5df2\u7ed3\u675f<br \/>\n        cv.wait(lk, []{ return !data_queue.empty() || done; });<\/p>\n<p>        \/\/ \u68c0\u67e5\u662f\u5426\u7ed3\u675f\u4e14\u961f\u5217\u4e3a\u7a7a<br \/>\n        if (done &amp;&amp; data_queue.empty()) {<br \/>\n            break;<br \/>\n        }<\/p>\n<p>        \/\/ \u5904\u7406\u6570\u636e<br \/>\n        if (!data_queue.empty()) {<br \/>\n            int data &#061; data_queue.front();<br \/>\n            data_queue.pop();<br \/>\n            std::cout &lt;&lt; &#034;Consumed: &#034; &lt;&lt; data &lt;&lt; &#034; by thread &#034; &lt;&lt; std::this_thread::get_id() &lt;&lt; std::endl;<br \/>\n        }<br \/>\n        lk.unlock(); \/\/ \u5904\u7406\u5b8c\u6570\u636e\u540e\u53ef\u4ee5\u63d0\u524d\u89e3\u9501<br \/>\n        \/\/ \u6a21\u62df\u5904\u7406\u8017\u65f6<br \/>\n        std::this_thread::sleep_for(std::chrono::milliseconds(100));<br \/>\n    }<br \/>\n}<\/p>\n<p>int main() {<br \/>\n    std::thread prod(producer);<br \/>\n    std::thread cons1(consumer);<br \/>\n    std::thread cons2(consumer);<\/p>\n<p>    prod.join();<br \/>\n    cons1.join();<br \/>\n    cons2.join();<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<h4>\u26a0\ufe0f \u56db\u3001\u91cd\u8981\u6ce8\u610f\u4e8b\u9879<\/h4>\n<li>\u4e0e\u9501\u914d\u5408&#xff1a;wait\u5fc5\u987b\u914d\u5408std::unique_lock&lt;std::mutex&gt;\u4f7f\u7528&#xff0c;\u56e0\u4e3a\u5b83\u9700\u8981\u5728\u7b49\u5f85\u671f\u95f4\u89e3\u9501\u5e76\u5728\u5524\u9192\u540e\u91cd\u65b0\u52a0\u9501\u3002<\/li>\n<li>\u8c13\u8bcd\u68c0\u67e5&#xff1a;\u5f3a\u70c8\u5efa\u8bae\u4f7f\u7528\u5e26\u8c13\u8bcd\u7684wait\u7248\u672c&#xff0c;\u5b83\u81ea\u52a8\u5904\u7406\u865a\u5047\u5524\u9192\u5e76\u4fdd\u8bc1\u6761\u4ef6\u771f\u6b63\u6210\u7acb\u3002<\/li>\n<li>\u9501\u7684\u4f5c\u7528\u57df&#xff1a;\n<ul>\n<li>\u5728\u8c03\u7528notify_one()\u6216notify_all()\u65f6&#xff0c;\u4e0d\u5f3a\u5236\u8981\u6c42\u6301\u6709\u9501\u3002\u4f46\u6301\u6709\u9501\u65f6\u901a\u77e5\u53ef\u4ee5\u907f\u514d\u4e00\u4e9b\u7ade\u6001\u6761\u4ef6&#xff08;\u4f8b\u5982&#xff0c;\u5728\u68c0\u67e5\u6761\u4ef6\u540e\u3001\u5f00\u59cb\u7b49\u5f85\u524d\u53d1\u751f\u901a\u77e5&#xff09;\u3002<\/li>\n<li>\u5728\u4fee\u6539\u6761\u4ef6&#xff08;\u5982\u8bbe\u7f6edone\u6216\u4fee\u6539data_queue&#xff09;\u65f6&#xff0c;\u5fc5\u987b\u6301\u6709\u9501\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u907f\u514d\u901a\u77e5\u4e22\u5931&#xff1a;\u786e\u4fdd\u5728\u4fee\u6539\u6761\u4ef6\u540e\u53ca\u65f6\u901a\u77e5\u3002\u5982\u679c\u4fee\u6539\u6761\u4ef6\u540e\u6ca1\u6709\u901a\u77e5&#xff0c;\u7b49\u5f85\u7ebf\u7a0b\u53ef\u80fd\u6c38\u8fdc\u963b\u585e\u3002<\/li>\n<li>notify_one vs notify_all&#xff1a;\u6839\u636e\u573a\u666f\u9009\u62e9\u3002notify_one\u6548\u7387\u66f4\u9ad8&#xff0c;\u4f46\u53ef\u80fd\u53ea\u5524\u9192\u4e00\u4e2a\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u7ebf\u7a0b&#xff08;\u5982\u679c\u8c13\u8bcd\u590d\u6742&#xff09;&#xff1b;notify_all\u66f4\u7b80\u5355\u4f46\u53ef\u80fd\u5f15\u8d77\u4e0d\u5fc5\u8981\u7684\u5524\u9192&#xff08;\u60ca\u7fa4\u6548\u5e94&#xff09;\u3002<\/li>\n<h4>&#x1f4a1; \u4e94\u3001\u603b\u7ed3<\/h4>\n<p>std::condition_variable\u662f\u5b9e\u73b0\u7ebf\u7a0b\u95f4\u9ad8\u6548\u534f\u4f5c&#xff08;\u7279\u522b\u662f\u751f\u4ea7\u8005-\u6d88\u8d39\u8005\u6a21\u578b&#xff09;\u7684\u5173\u952e\u5de5\u5177\u3002\u6b63\u786e\u4f7f\u7528\u5b83\u9700\u8981\u7406\u89e3\u5176\u4e0e\u4e92\u65a5\u9501\u7684\u914d\u5408\u3001\u7b49\u5f85\u8c13\u8bcd\u7684\u68c0\u67e5\u4ee5\u53ca\u901a\u77e5\u7684\u65f6\u673a\u3002\u52a1\u5fc5\u4f7f\u7528\u5e26\u8c13\u8bcd\u7684wait\u6765\u907f\u514d\u865a\u5047\u5524\u9192\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u7684&#xff0c;\u6211\u4eec\u6765\u8be6\u7ec6\u63a2\u8ba8C11\u6807\u51c6\u5e93\u4e2d\u7684std::condition_variable&#xff08;\u6761\u4ef6\u53d8\u91cf&#xff09;\u3002&#x1f9e9; \u4e00\u3001\u6761\u4ef6\u53d8\u91cf\u662f\u4ec0\u4e48&#xff1f;std::condition_variable \u662fC11\u5f15\u5165\u7684\u7ebf\u7a0b\u540c\u6b65\u539f\u8bed&#xff0c;\u7528\u4e8e\u5b9e\u73b0\u7ebf\u7a0b\u95f4\u7684\u7b49\u5f85\/\u901a\u77e5\u673a\u5236\u3002\u5b83\u5141\u8bb8\u4e00\u4e2a\u6216\u591a\u4e2a\u7ebf\u7a0b\u963b\u585e\u7b49\u5f85&#xff0c;\u76f4\u5230\u88ab\u5176\u4ed6\u7ebf\u7a0b\u901a\u77e5\u67d0\u4e2a\u6761\u4ef6\u6210\u7acb&#xff08;\u6216\u8d85\u65f6&#xff09;\u3002\u5b83\u901a\u5e38\u4e0estd::mutex\u548cstd::unique<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55],"topic":[],"class_list":["post-66597","post","type-post","status-publish","format-standard","hentry","category-server","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/66597.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u597d\u7684&#xff0c;\u6211\u4eec\u6765\u8be6\u7ec6\u63a2\u8ba8C11\u6807\u51c6\u5e93\u4e2d\u7684std::condition_variable&#xff08;\u6761\u4ef6\u53d8\u91cf&#xff09;\u3002&#x1f9e9; \u4e00\u3001\u6761\u4ef6\u53d8\u91cf\u662f\u4ec0\u4e48&#xff1f;std::condition_variable \u662fC11\u5f15\u5165\u7684\u7ebf\u7a0b\u540c\u6b65\u539f\u8bed&#xff0c;\u7528\u4e8e\u5b9e\u73b0\u7ebf\u7a0b\u95f4\u7684\u7b49\u5f85\/\u901a\u77e5\u673a\u5236\u3002\u5b83\u5141\u8bb8\u4e00\u4e2a\u6216\u591a\u4e2a\u7ebf\u7a0b\u963b\u585e\u7b49\u5f85&#xff0c;\u76f4\u5230\u88ab\u5176\u4ed6\u7ebf\u7a0b\u901a\u77e5\u67d0\u4e2a\u6761\u4ef6\u6210\u7acb&#xff08;\u6216\u8d85\u65f6&#xff09;\u3002\u5b83\u901a\u5e38\u4e0estd::mutex\u548cstd::unique\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/66597.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-26T15:41:10+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66597.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/66597.html\",\"name\":\"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-26T15:41:10+00:00\",\"dateModified\":\"2026-01-26T15:41:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/66597.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/66597.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66597.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/66597.html","og_locale":"zh_CN","og_type":"article","og_title":"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u597d\u7684&#xff0c;\u6211\u4eec\u6765\u8be6\u7ec6\u63a2\u8ba8C11\u6807\u51c6\u5e93\u4e2d\u7684std::condition_variable&#xff08;\u6761\u4ef6\u53d8\u91cf&#xff09;\u3002&#x1f9e9; \u4e00\u3001\u6761\u4ef6\u53d8\u91cf\u662f\u4ec0\u4e48&#xff1f;std::condition_variable \u662fC11\u5f15\u5165\u7684\u7ebf\u7a0b\u540c\u6b65\u539f\u8bed&#xff0c;\u7528\u4e8e\u5b9e\u73b0\u7ebf\u7a0b\u95f4\u7684\u7b49\u5f85\/\u901a\u77e5\u673a\u5236\u3002\u5b83\u5141\u8bb8\u4e00\u4e2a\u6216\u591a\u4e2a\u7ebf\u7a0b\u963b\u585e\u7b49\u5f85&#xff0c;\u76f4\u5230\u88ab\u5176\u4ed6\u7ebf\u7a0b\u901a\u77e5\u67d0\u4e2a\u6761\u4ef6\u6210\u7acb&#xff08;\u6216\u8d85\u65f6&#xff09;\u3002\u5b83\u901a\u5e38\u4e0estd::mutex\u548cstd::unique","og_url":"https:\/\/www.wsisp.com\/helps\/66597.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-26T15:41:10+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/66597.html","url":"https:\/\/www.wsisp.com\/helps\/66597.html","name":"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-26T15:41:10+00:00","dateModified":"2026-01-26T15:41:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/66597.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/66597.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/66597.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++11\u6761\u4ef6\u53d8\u91cf\uff1a\u7ebf\u7a0b\u540c\u6b65\u6838\u5fc3\u6280\u5de7"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=66597"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66597\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=66597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=66597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=66597"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=66597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}