新聞中心
這里有您想知道的互聯(lián)網營銷解決方案
c/c++多線程簡單玩法快速掌握簡單易懂
#include#include #include #include using namespace std; using namespace std::this_thread; void Msg() { MessageBox(0,L"線程啟動",L"32",0); } void MsgA(int num) //線程玩法2222 { std::cout< threads; for (int i = 0;i < 10;i++) { threads.push_back(new thread(MsgA,5));//創(chuàng)建線程 地址存在vector } for (auto th : threads)//創(chuàng)建完在執(zhí)行 { th->join(); } cin.get(); } int main1445()//線程玩法111 //改名了 { auto n = thread::hardware_concurrency(); cout << "You CPU is " << n << endl; //堅持CPU核心 cout << "You CPU thread " << get_id() << endl;//獲取線程ID //創(chuàng)建線程 thread threadl(Msg); thread thread2(Msg); threadl.join(); //執(zhí)行 必須等待執(zhí)行 thread2.join(); //執(zhí)行 getchar(); return 0; }
創(chuàng)新互聯(lián)公司是一家專業(yè)提供南票企業(yè)網站建設,專注與成都網站設計、網站建設、H5建站、小程序制作等業(yè)務。10年已為南票眾多企業(yè)、政府機構等服務。創(chuàng)新互聯(lián)專業(yè)網絡公司優(yōu)惠進行中。
分享標題:c/c++多線程簡單玩法快速掌握簡單易懂
地址分享:http://fisionsoft.com.cn/article/gdiogd.html