<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ### thread操作 ***** **join** 主線程等待子線程執行完再關閉 ``` std::thread mytobj(myPrint); mytobj.join(); std::cout << "主線程收尾,最終主線程安全正常推出!" << std::endl; ``` **detach** 主線程跟子線程沒有太大關系,主線程可以不必等待子線程執行完再關閉 ``` std::thread mytobj(myPrint); mytobj.detach(); std::cout << "主線程收尾,最終主線程安全正常推出!" << std::endl; ``` **joinable** 返回TRUE 表示可以join或者detach,返回FALSE則表示不能join或detach ``` std::thread mytobj(myPrint); if (mytobj.joinable()) mytobj.join(); ``` ### **其他創建線程的方式** **1,類創建** ```c++ class MyClass { public: MyClass(); ~MyClass(); void operator() () { std::cout << "我的線程operator()開始執行了" << std::endl; //... std::cout << "我的線程operator()結束執行了" << std::endl; } private: }; int main() { MyClass mc; std::thread mytob2(mc); mytob2.join();//等待子線程結束 std::cout << "主線程收尾,最終主線程安全正常推出!" << std::endl; //當主線程銷毀時這個mc對象不存在了,但是這個對象已經被復制到線程中去了 只要mc沒有指針沒有引用,就不會有問題 ``` **2.lamthread創建** ```c++ auto mylamthread = [] { std::cout << "我的線程mylamthread()開始執行了" << std::endl; std::cout << "我的線程operator()執行結束了" << std::endl; }; std::thread mytobj4(mylamthread); mytobj4.detach(); ```
                  <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>

                              哎呀哎呀视频在线观看