#include <iostream> #include <thread> #include <windows.h> #include <vector>using Namespace std;using namespace std::this_thread;void msg () { MessageBox (0,L "thread Start", L "32" , 0);} VOID&NBSP;MSGA (int num) //threading 2222{ std::cout<<get_id () << "num=" << num << endl;} Void main () //thread play 2222{ vector<thread *>threads; for (int i = 0;i < 10;i++) { threads.push_back (New thread (MsgA,5));//Create Thread Address exists vector } for (auto th : threads)//created in execution { th->join (); } cin.get ();} int main1445 ()//thread play 111 //renamed { auto n = thread::hardware _concurrency (); cout << "you cpu is " << n < < endl; //stick to CPU core cout << "you cpu thread " << get_id () << endl;//get thread id // Create Thread thread threadl (msg); thread thread2 (msg); threadl.join () ; //execution must wait for execution thread2.join (); //Execution getchar ( ); return 0;}
650) this.width=650; "title=" Thread. PNG "style=" Float:none; "src=" Http://s3.51cto.com/wyfs02/M02/8B/08/wKiom1hCPNvyOAkHAAB2VeHMzv8873.png-wh_ 500x0-wm_3-wmp_4-s_4043957692.png "alt=" Wkiom1hcpnvyoakhaab2vehmzv8873.png-wh_50 "/>
650) this.width=650; "Title=" thread2. PNG "style=" Float:none; "src=" Http://s3.51cto.com/wyfs02/M02/8B/04/wKioL1hCPNuTnL4iAACrKcR2uio623.png-wh_ 500x0-wm_3-wmp_4-s_3499992297.png "alt=" Wkiol1hcpnutnl4iaacrkcr2uio623.png-wh_50 "/>
This article is from the "12148490" blog, please be sure to keep this source http://12158490.blog.51cto.com/12148490/1879080
Easy-to-understand simple gameplay