{"id":115336,"date":"2026-10-11T23:32:46","date_gmt":"2026-10-11T15:32:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115336.html"},"modified":"2026-10-11T23:32:46","modified_gmt":"2026-10-11T15:32:46","slug":"c%e5%a4%9a%e7%ba%bf%e7%a8%8b%e8%b5%84%e6%ba%90%e8%ae%bf%e9%97%ae%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115336.html","title":{"rendered":"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898"},"content":{"rendered":"<h2>\u4e00 \u7ade\u6001\u6761\u4ef6&#xff08;\u7ade\u4e89\u6761\u4ef6&#xff09;<\/h2>\n<p>\u5b9a\u4e49&#xff1a;\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199\u540c\u4e00\u4efd\u5171\u4eab\u6570\u636e&#xff0c;\u6ca1\u6709\u52a0\u4efb\u4f55\u4fdd\u62a4&#xff0c;\u6700\u7ec8\u8ba1\u7b97\u7ed3\u679c\u9519\u4e71\u3002<\/p>\n<p>\u539f\u7406&#xff1a;\u4e00\u6761\u53d8\u91cf\u81ea\u589ecnt&#043;&#043;\u5728CPU\u4e0d\u662f\u4e00\u6761\u6307\u4ee4&#xff0c;\u4f1a\u62c6\u5206\u6210\u4e09\u6b65&#xff1a;\u8bfb-&gt;\u4fee\u6539-&gt;\u5199\u56de\u3002<\/p>\n<p>\u4e24\u4e2a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c&#xff0c;\u6b65\u9aa4\u7a7f\u63d2\u6253\u4e71&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u6570\u636e\u9519\u8bef\u3002<\/p>\n<p>\u4f8b\u5b50&#xff1a;cnt\u521d\u59cb&#061;0&#xff0c;\u4e24\u4e2a\u7ebf\u7a0b\u90fd\u6267\u884ccnt&#043;&#043;&#xff0c;\u9884\u671f\u53d8\u62102&#xff0c;\u5b9e\u9645\u53ef\u80fd\u7ed3\u679c\u4e3a1\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u5f0f&#xff1a;\u4e92\u65a5\u9501mutex&#xff0c;\u539f\u5b50\u9501atomic\u3002<\/p>\n<\/p>\n<h2>\u4e8c std::thread<\/h2>\n<p>C&#043;&#043;11\u7ebf\u7a0b\u7c7b&#xff0c;\u7528\u6765\u521b\u5efa\u5e76\u542f\u52a8\u5b50\u7ebf\u7a0b&#xff0c;\u6267\u884c\u4efb\u52a1\u3002<\/p>\n<p>\u00a0 t.join()&#xff1a;\u4e3b\u7ebf\u7a0b\u963b\u585e\u7b49\u5f85\u5b50\u7ebf\u7a0b\u6267\u884c\u5b8c\u6bd5&#xff0c;\u56de\u6536\u7ebf\u7a0b\u8d44\u6e90&#xff1b;\u4e3b\u7ebf\u7a0b\u4e0d\u7b49\u5b8c\u4e0d\u80fd\u5f80\u4e0b\u8d70&#xff1b;<\/p>\n<p>\u00a0 t.detach()&#xff1a;\u5206\u79bb\u7ebf\u7a0b&#xff0c;\u5b50\u7ebf\u7a0b\u540e\u53f0\u72ec\u7acb\u8dd1&#xff0c;\u4e3b\u7ebf\u7a0b\u4e0d\u7528\u7b49\u5f85&#xff1b;\u98ce\u9669&#xff1a;\u4e3b\u7ebf\u7a0b\u9000\u51fa&#xff0c;\u5b50\u7ebf\u7a0b\u76f4\u63a5\u88ab\u6740\u6b7b\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;thread&gt;<br \/>\nusing namespace std;<\/p>\n<p>void task()<br \/>\n{<br \/>\n    cout &lt;&lt; &#034;\u5b50\u7ebf\u7a0b\u8fd0\u884c&#034; &lt;&lt; endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    thread t(task); \/\/ \u521b\u5efa\u7ebf\u7a0b&#xff0c;\u7acb\u523b\u542f\u52a8<br \/>\n    t.join();       \/\/ \u7b49\u5f85\u5b50\u7ebf\u7a0b\u7ed3\u675f<br \/>\n    cout &lt;&lt; &#034;\u4e3b\u7ebf\u7a0b\u7ed3\u675f&#034; &lt;&lt; endl;<br \/>\n    return 0;<br \/>\n}<\/p>\n<h2>\u4e09 stad::mutex\u4e92\u65a5\u9501<\/h2>\n<p>\u4f5c\u7528&#xff1a;\u4fdd\u62a4\u5171\u4eab\u8d44\u6e90&#xff0c;\u540c\u4e00\u65f6\u523b\u53ea\u5141\u8bb8\u4e00\u4e2a\u7ebf\u7a0b\u62ff\u5230\u9501&#xff0c;\u8bbf\u95ee\u4e34\u754c\u533a\u4ee3\u7801&#xff0c;\u907f\u514d\u7ade\u6001\u6761\u4ef6\u3002<\/p>\n<p>\u00a0 lock()&#xff1a;\u5c1d\u8bd5\u83b7\u53d6\u9501&#xff1b;\u9501\u88ab\u5360\u7528\u65f6&#xff0c;\u5f53\u524d\u7ebf\u7a0b\u963b\u585e\u4f11\u7720&#xff0c;\u7b49\u522b\u4eba\u91ca\u653e\u3002<\/p>\n<p>\u00a0 unlock()&#xff1a;\u91ca\u653e\u9501&#xff0c;\u5176\u4ed6\u7b49\u5f85\u7ebf\u7a0b\u53ef\u4ee5\u67aa\u9501\u3002<\/p>\n<p>\u7f3a\u70b9&#xff1a;\u624b\u52a8lock&#xff0c;unlock\u5f88\u5371\u9669\u3002\u5982\u679c\u4e2d\u95f4\u4ee3\u7801return\u6216\u8005\u629b\u51fa\u5f02\u5e38&#xff0c;unlock\u6ca1\u6709\u673a\u4f1a\u6267\u884c-&gt;\u6b7b\u9501\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;thread&gt;<br \/>\n#include &lt;mutex&gt;<br \/>\nusing namespace std;<\/p>\n<p>mutex mtx;<br \/>\nint cnt &#061; 0;<\/p>\n<p>void add()<br \/>\n{<br \/>\n    mtx.lock();   \/\/ \u624b\u52a8\u4e0a\u9501<br \/>\n    cnt&#043;&#043;;        \/\/ \u4e34\u754c\u533a&#xff0c;\u540c\u4e00\u65f6\u95f4\u53ea\u80fd\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c<br \/>\n    mtx.unlock(); \/\/ \u624b\u52a8\u89e3\u9501<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    thread t1(add);<br \/>\n    thread t2(add);<br \/>\n    t1.join();<br \/>\n    t2.join();<br \/>\n    cout &lt;&lt; cnt &lt;&lt; endl;<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u98ce\u9669\u6f14\u793a&#xff08;\u4f1a\u9020\u6210\u6b7b\u9501&#xff09;<\/p>\n<p>void add()<br \/>\n{<br \/>\n    mtx.lock();<br \/>\n    cnt&#043;&#043;;<br \/>\n    if (cnt &gt; 0)<br \/>\n        return; \/\/ \u51fd\u6570\u76f4\u63a5return&#xff0c;\u4e0b\u9762unlock\u6267\u884c\u4e0d\u5230&#xff01;<br \/>\n    mtx.unlock();<br \/>\n}<\/p>\n<p>\u4e00\u65e6return\u6216\u8005\u629b\u51fa\u5f02\u5e38&#xff0c;unlock\u4e0d\u4f1a\u6267\u884c&#xff0c;\u9501\u6c38\u4e45\u5360\u7528-&gt;\u6b7b\u9501\u3002<\/p>\n<\/p>\n<h2>\u56db std::lock_guard ***\u9ad8\u9891&#xff08;RAII&#xff09;<\/h2>\n<p>RAII\u601d\u8def&#xff1a;\u6784\u9020\u51fd\u6570\u4e0a\u9501&#xff0c;\u6790\u6784\u51fd\u6570\u81ea\u52a8\u89e3\u9501\u3002<\/p>\n<p>\u521b\u5efalock_guard\u5bf9\u8c61\u81ea\u52a8lock()&#xff1b;\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df&#xff08;\u82b1\u62ec\u53f7\u7ed3\u675f&#xff0c;return&#xff0c;\u5f02\u5e38&#xff09;&#xff0c;\u81ea\u52a8\u6790\u6784\u8c03\u7528unlock()\u3002<\/p>\n<p>\u4e0d\u9700\u8981\u624b\u52a8\u5199unlock&#xff0c;\u907f\u514d\u5fd8\u8bb0\u91ca\u653e\u9501\u9020\u6210\u6b7b\u9501&#xff0c;\u5de5\u7a0b\u4ee3\u7801\u9996\u9009\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;thread&gt;<br \/>\n#include &lt;mutex&gt;<br \/>\nusing namespace std;<\/p>\n<p>mutex mtx;<br \/>\nint cnt &#061; 0;<\/p>\n<p>void add()<br \/>\n{<br \/>\n    \/\/ \u521b\u5efalg\u5bf9\u8c61&#xff0c;\u6784\u9020\u51fd\u6570\u81ea\u52a8lock()<br \/>\n    lock_guard&lt;mutex&gt; lg(mtx);<br \/>\n    cnt&#043;&#043;;<\/p>\n<p>    \/\/ \u5c31\u7b97\u8fd9\u91ccreturn \/ throw\u5f02\u5e38&#xff0c;lg\u51fa\u4f5c\u7528\u57df\u4f1a\u81ea\u52a8\u6790\u6784&#xff0c;\u8c03\u7528unlock<br \/>\n    \/\/ \u79bb\u5f00{}&#xff0c;lg\u9500\u6bc1&#xff0c;\u81ea\u52a8\u89e3\u9501<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    thread t1(add);<br \/>\n    thread t2(add);<br \/>\n    t1.join();<br \/>\n    t2.join();<br \/>\n    cout &lt;&lt; cnt &lt;&lt; endl;<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u539f\u7406&#xff1a;\u5bf9\u8c61\u751f\u547d\u5468\u671f\u7ed1\u5b9a\u4f5c\u7528\u57df&#xff0c;\u4e0d\u7528\u624b\u52a8\u5199unlock&#xff0c;\u89c4\u907f\u5fd8\u8bb0\u91ca\u653e\u9501\u7684\u95ee\u9898&#xff1b;<\/p>\n<\/p>\n<h2>\u4e94 std::condition_variable\u6761\u4ef6\u53d8\u91cf&#xff08;\u751f\u4ea7\u8005\u6d88\u8d39\u8005&#xff09;<\/h2>\n<p>\u4f5c\u7528&#xff1a;\u7ebf\u7a0b\u7b49\u5f85&#xff0c;\u5524\u9192&#xff0c;\u907f\u514d\u5fd9\u7b49\u3002<\/p>\n<p>\u5fc5\u987b\u914d\u5408mutex\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p>\u00a0 wait(mutex)&#xff1a;\u91ca\u653e\u9501&#xff0c;\u7ebf\u7a0b\u4f11\u7720\u7b49\u5f85&#xff1b;\u88ab\u5524\u9192\u540e&#xff1b;\u91cd\u65b0\u62a2\u5360\u9501\u3002\u7ee7\u7eed\u6267\u884c\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 <font face=\"monospace\">wait<\/font>\u505a\u7684\u4e24\u4ef6\u5173\u952e\u4e8b&#xff1a; \u2460 \u8c03\u7528 wait \u7684\u65f6\u5019\u81ea\u52a8\u91ca\u653e mutex&#xff0c;\u522b\u7684\u7ebf\u7a0b&#xff08;\u751f\u4ea7\u8005&#xff09;\u624d\u6709\u673a\u4f1a\u62ff\u00a0 \u00a0 \u00a0 \u00a0 \u5230\u9501\u4fee\u6539\u6761\u4ef6&#xff1b; \u2461 \u6536\u5230 notify \u5524\u9192\u540e&#xff0c;\u91cd\u65b0\u62a2\u5360 mutex&#xff0c;\u62ff\u5230\u9501\u4e4b\u540e&#xff0c;\u518d\u53bb\u5224\u65ad\u6761\u4ef6\u3002<\/p>\n<p>\u00a0 notify_one()&#xff1a;\u5524\u9192\u4e00\u4e2a\u6b63\u5728\u7b49\u5f85\u7684\u7ebf\u7a0b\u3002<\/p>\n<p>\u00a0 notify_all()&#xff1a;\u5524\u9192\u5168\u90e8\u7b49\u5f85\u7684\u7ebf\u7a0b\u3002<\/p>\n<p>\u7ecf\u5178\u573a\u666f&#xff1a;\u751f\u4ea7\u8005\u6d88\u8d39\u8005\u6a21\u578b<\/p>\n<p>\u751f\u4ea7\u8005\u5f80\u961f\u5217\u653e\u6570\u636e&#xff1b;\u961f\u5217\u7a7a\u7684\u65f6\u5019&#xff0c;\u6d88\u8d39\u8005\u8c03\u7528wait()\u4f11\u7720&#xff0c;\u4e0d\u4e00\u76f4\u5faa\u73af\u8017CPU\u3002\u751f\u4ea7\u8005\u751f\u4ea7\u5b8c\u6570\u636e\u8c03\u7528notify&#xff0c;\u5524\u9192\u6d88\u8d39\u8005\u53d6\u6570\u636e\u3002<\/p>\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;<br \/>\nusing namespace std;<\/p>\n<p>mutex mtx;<br \/>\ncondition_variable cv;<br \/>\nqueue&lt;int&gt; q;<\/p>\n<p>\/\/ \u751f\u4ea7\u8005&#xff1a;\u5f80\u961f\u5217\u653e\u6570\u636e<br \/>\nvoid producer()<br \/>\n{<br \/>\n    for(int i &#061; 1; i &lt;&#061; 3; i&#043;&#043;)<br \/>\n    {<br \/>\n        unique_lock&lt;mutex&gt; lock(mtx);<br \/>\n        q.push(i);<br \/>\n        cout &lt;&lt; &#034;\u751f\u4ea7&#xff1a;&#034; &lt;&lt; i &lt;&lt; endl;<br \/>\n        cv.notify_one(); \/\/ \u5524\u91921\u4e2a\u7b49\u5f85\u7684\u6d88\u8d39\u8005<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u6d88\u8d39\u8005&#xff1a;\u4ece\u961f\u5217\u53d6\u6570\u636e<br \/>\nvoid consumer()<br \/>\n{<br \/>\n    while(true)<br \/>\n    {<br \/>\n        unique_lock&lt;mutex&gt; lock(mtx);<br \/>\n        \/\/ \u961f\u5217\u7a7a&#xff0c;\u7b49\u5f85<br \/>\n        cv.wait(lock, [&amp;](){ return !q.empty(); });<br \/>\n        int val &#061; q.front();<br \/>\n        q.pop();<br \/>\n        cout &lt;&lt; &#034;\u6d88\u8d39&#xff1a;&#034; &lt;&lt; val &lt;&lt; endl;<br \/>\n    }<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    thread t1(producer);<br \/>\n    thread t2(consumer);<br \/>\n    t1.join();<br \/>\n    t2.detach();<br \/>\n    return 0;<br \/>\n}<\/p>\n<h2>\u516d std::atomic\u539f\u5b50\u53d8\u91cf&#xff08;\u65e0\u9501&#xff09;<\/h2>\n<p>\u65e0\u9501&#xff0c;\u786c\u4ef6\u5c42\u9762\u4fdd\u8bc1\u64cd\u4f5c\u4e0d\u53ef\u62c6\u5206&#xff08;\u539f\u5b50&#xff09;<\/p>\n<p>\u7b80\u5355\u53d8\u91cf\u8bfb\u5199&#xff0c;\u81ea\u589e\u4e0d\u7528mutex&#xff0c;\u4e0d\u4f1a\u4ea7\u751f\u7ade\u6001\u6761\u4ef6&#xff0c;\u6027\u80fd\u6bd4\u9501\u9ad8\u3002<\/p>\n<p>\u5c40\u9650&#xff1a;\u53ea\u9002\u5408\u5355\u4e2a\u7b80\u5355\u53d8\u91cf\u64cd\u4f5c&#xff0c;\u590d\u6742\u4e1a\u52a1\u903b\u8f91&#xff0c;\u591a\u884c\u4ee3\u7801\u7684\u4e34\u754c\u533a&#xff0c;\u8fd8\u662f\u8981mutex\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;thread&gt;<br \/>\n#include &lt;atomic&gt;<br \/>\nusing namespace std;<\/p>\n<p>atomic&lt;int&gt; cnt &#061; 0; \/\/ \u539f\u5b50\u53d8\u91cf<\/p>\n<p>void add()<br \/>\n{<br \/>\n    cnt&#043;&#043;; \/\/ \u786c\u4ef6\u4fdd\u8bc1\u81ea\u589e\u662f\u539f\u5b50\u64cd\u4f5c&#xff0c;\u4e0d\u7528\u52a0\u9501&#xff0c;\u4e0d\u4f1a\u7ade\u6001<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    thread t1(add);<br \/>\n    thread t2(add);<br \/>\n    t1.join();<br \/>\n    t2.join();<br \/>\n    cout &lt;&lt; cnt &lt;&lt; endl;<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u4f18\u70b9&#xff1a;\u65e0\u9501&#xff0c;\u6027\u80fd\u9ad8\u4e8e mutex<\/p>\n<p>\u5c40\u9650&#xff1a;\u53ea\u80fd\u5904\u7406\u5355\u4e2a\u53d8\u91cf\u7b80\u5355\u64cd\u4f5c\u3002 \u5982\u679c\u6709\u591a\u884c\u4ee3\u7801\u3001\u591a\u4e2a\u53d8\u91cf\u9700\u8981\u4fdd\u62a4&#xff0c;atomic \u5c31\u4e0d\u591f\u7528&#xff0c;\u5fc5\u987b mutex\u3002 \u4e3e\u4f8b&#xff1a;if(cnt &gt;0) cnt&#8211;; \u8fd9\u4e24\u884c\u4e0d\u662f\u539f\u5b50\u7684&#xff0c;atomic \u65e0\u6cd5\u4fdd\u62a4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00 \u7ade\u6001\u6761\u4ef6&#xff08;\u7ade\u4e89\u6761\u4ef6&#xff09;\u5b9a\u4e49&#xff1a;\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199\u540c\u4e00\u4efd\u5171\u4eab\u6570\u636e&#xff0c;\u6ca1\u6709\u52a0\u4efb\u4f55\u4fdd\u62a4&#xff0c;\u6700\u7ec8\u8ba1\u7b97\u7ed3\u679c\u9519\u4e71\u3002\u539f\u7406&#xff1a;\u4e00\u6761\u53d8\u91cf\u81ea\u589ecnt\u5728CPU\u4e0d\u662f\u4e00\u6761\u6307\u4ee4&#xff0c;\u4f1a\u62c6\u5206\u6210\u4e09\u6b65&#xff1a;\u8bfb-&gt;\u4fee\u6539-&gt;\u5199\u56de\u3002\u4e24\u4e2a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c&#xff0c;\u6b65\u9aa4\u7a7f\u63d2\u6253\u4e71&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u6570\u636e\u9519\u8bef\u3002\u4f8b\u5b50&#xff1a;cnt\u521d\u59cb0&#xff0c;\u4e24\u4e2a\u7ebf\u7a0b\u90fd\u6267\u884ccnt&#xff0c;\u9884\u671f\u53d8\u62102&#xff0c;\u5b9e\u9645<\/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-115336","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++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898 - \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\/115336.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00 \u7ade\u6001\u6761\u4ef6&#xff08;\u7ade\u4e89\u6761\u4ef6&#xff09;\u5b9a\u4e49&#xff1a;\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199\u540c\u4e00\u4efd\u5171\u4eab\u6570\u636e&#xff0c;\u6ca1\u6709\u52a0\u4efb\u4f55\u4fdd\u62a4&#xff0c;\u6700\u7ec8\u8ba1\u7b97\u7ed3\u679c\u9519\u4e71\u3002\u539f\u7406&#xff1a;\u4e00\u6761\u53d8\u91cf\u81ea\u589ecnt\u5728CPU\u4e0d\u662f\u4e00\u6761\u6307\u4ee4&#xff0c;\u4f1a\u62c6\u5206\u6210\u4e09\u6b65&#xff1a;\u8bfb-&gt;\u4fee\u6539-&gt;\u5199\u56de\u3002\u4e24\u4e2a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c&#xff0c;\u6b65\u9aa4\u7a7f\u63d2\u6253\u4e71&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u6570\u636e\u9519\u8bef\u3002\u4f8b\u5b50&#xff1a;cnt\u521d\u59cb0&#xff0c;\u4e24\u4e2a\u7ebf\u7a0b\u90fd\u6267\u884ccnt&#xff0c;\u9884\u671f\u53d8\u62102&#xff0c;\u5b9e\u9645\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115336.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-11T15:32:46+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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115336.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115336.html\",\"name\":\"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-11T15:32:46+00:00\",\"dateModified\":\"2026-10-11T15:32:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115336.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115336.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115336.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898\"}]},{\"@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++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898 - \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\/115336.html","og_locale":"zh_CN","og_type":"article","og_title":"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00 \u7ade\u6001\u6761\u4ef6&#xff08;\u7ade\u4e89\u6761\u4ef6&#xff09;\u5b9a\u4e49&#xff1a;\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199\u540c\u4e00\u4efd\u5171\u4eab\u6570\u636e&#xff0c;\u6ca1\u6709\u52a0\u4efb\u4f55\u4fdd\u62a4&#xff0c;\u6700\u7ec8\u8ba1\u7b97\u7ed3\u679c\u9519\u4e71\u3002\u539f\u7406&#xff1a;\u4e00\u6761\u53d8\u91cf\u81ea\u589ecnt\u5728CPU\u4e0d\u662f\u4e00\u6761\u6307\u4ee4&#xff0c;\u4f1a\u62c6\u5206\u6210\u4e09\u6b65&#xff1a;\u8bfb-&gt;\u4fee\u6539-&gt;\u5199\u56de\u3002\u4e24\u4e2a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c&#xff0c;\u6b65\u9aa4\u7a7f\u63d2\u6253\u4e71&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u6570\u636e\u9519\u8bef\u3002\u4f8b\u5b50&#xff1a;cnt\u521d\u59cb0&#xff0c;\u4e24\u4e2a\u7ebf\u7a0b\u90fd\u6267\u884ccnt&#xff0c;\u9884\u671f\u53d8\u62102&#xff0c;\u5b9e\u9645","og_url":"https:\/\/www.wsisp.com\/helps\/115336.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-11T15:32:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115336.html","url":"https:\/\/www.wsisp.com\/helps\/115336.html","name":"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-11T15:32:46+00:00","dateModified":"2026-10-11T15:32:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115336.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115336.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115336.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++\u591a\u7ebf\u7a0b\u8d44\u6e90\u8bbf\u95ee\u95ee\u9898"}]},{"@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\/115336","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=115336"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115336\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115336"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}