C++ 线程问题
如下我的代码,是按书上抄的,运行结果为什么不对啊。我注释了Sleep(10),线程的内容不应该显示的,怎么会这样呢?#include<windows.h>#include...
如下我的代码,是按书上抄的,运行结果为什么不对啊。我注释了Sleep(10),线程的内容不应该显示的,怎么会这样呢?
#include<windows.h>
#include<iostream>
using namespace std;
void main()
{
HANDLE hThread1;
hThread1 = CreateThread(NULL, 0, Fun1Proc, NULL, 0, NULL);
CloseHandle(hThread1);
cout << "mian thread is runing" << endl;
Sleep(10);
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
cout << "thread1 is runing" << endl;
return 0;
} 展开
#include<windows.h>
#include<iostream>
using namespace std;
void main()
{
HANDLE hThread1;
hThread1 = CreateThread(NULL, 0, Fun1Proc, NULL, 0, NULL);
CloseHandle(hThread1);
cout << "mian thread is runing" << endl;
Sleep(10);
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
cout << "thread1 is runing" << endl;
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询