1 #include <iostream>
2 #include <thread>
3 #include <Windows.h>
4 using namespace std;
5
6 void run()
7 {
8 MessageBoxA(0, "0", "0", 0);
9 }
10
11 void showmsg(const char *str1,const char *str2)
12 {
13 MessageBoxA(0, str1, str2, 0);
14 }
15
16 void main()
17 {
18 ////栈上开辟
19 ////并行,异步,非阻塞
20 //thread t1(run);
21 //thread t2(run);
22
23 //thread t[2]{ thread(run),thread(run) };
24
25 ////堆上开辟
26 //thread *pthread(new thread(run));
27
28 //多线程传递参数
29 thread th1(showmsg, "1", "1");
30 thread th2(showmsg, "2", "2");
31 thread th3(showmsg, "3", "3");
32
33 cin.get();
34 }