<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                一、傳遞臨時對象作為線程參數 (1,1)要避免的陷阱 **用detach的時候不推薦用引用,不允許用指針** ``` // ThreadError.cpp : 此文件包含 "main" 函數。程序執行將在此處開始并結束。 // #include "pch.h" #include <iostream> #include <thread> #include <string> using namespace std; //void myprint(const int &i, char *pmybuf) void myprint(const int i, const std::string& pmybuf) { std::cout << i << std::endl; std::cout << pmybuf.c_str() << std::endl;//指針為detach時,絕對會有問題 return; } int main() { //一、傳遞臨時對象作為線程參數 //(1,1)要避免的陷阱 //1. int mvar = 1; int &mvary = mvar; char mybuf[] = "this is test"; //thread mytobj(myprint, mvar, mybuf);//事實上存在mybuf都被回收了(main函數執行完了)系統采用mybuf轉string(不可以) thread mytobj(myprint,mvar,string(mybuf));//我們可以直接將mybuf轉換成string對象,這是一個可以保證在線程中用肯定有效的 mytobj.detach();//子線程和主線程分別執行 cout << "I Love You" << endl; std::cout << "Hello World!\n"; } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看