#include <windows.h>
#include <iostream.h>DWORD WINAPI Fun1Proc(
LPVOID lpParameter // thread data
);void main()
{
HANDLE hThread1;
hThread1 = CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);
CloseHandle(hThread1);
cout<<"main thread is runing"<<endl;
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
cout<<"thread1 is running"<<endl;
return 0;
}第一次运行结果,有时为:
main thread is runing
main thread is runing
thread1 is running而有时为:
main thread is runing请大家帮助分析一下,谢谢哈
#include <iostream.h>DWORD WINAPI Fun1Proc(
LPVOID lpParameter // thread data
);void main()
{
HANDLE hThread1;
hThread1 = CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);
CloseHandle(hThread1);
cout<<"main thread is runing"<<endl;
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
cout<<"thread1 is running"<<endl;
return 0;
}第一次运行结果,有时为:
main thread is runing
main thread is runing
thread1 is running而有时为:
main thread is runing请大家帮助分析一下,谢谢哈
解决方案 »
- 如何制作迷你模式.
- 边缘定位问题
- 有关计算机水平考试的问题???
- CListCtrl排序问题
- 急,在线等待,程序调用外部命令的用法~~~发300分,解决问题后开新帖发分
- 又一个窗口切分问题?????????
- 请问如何使用::CoCreateInstanceEx,编译总是未定义,头文件和库都加过了(vc++6)
- 编译时出现 “符号不能用在 using 声明中”; “不是“`global namespace'”的成员”
- float型数据如何倒序写文件
- 求教一个关于hook与DLL的问题
- 匿名管道[继续],和子进程数据交换发生堵塞。[附我的测试代码]
- 谁有skin++ 的 corona.ssk 皮肤呀
main thread is runing
main thread is runing
thread1 is running 而有时为:
main thread is runing //子线程还未执行,主线程就结束了。两者的执行顺序不固定。
main thread is runing //子线程还未执行,主线程就结束了。
这个 是因为主线程获得了时间片,因此它能够运行,但是主线程执行完了main函数退出,进程也就退出了,这时还没有执行的线程都要退出
main thread is runing
main thread is runing
运行两次没想明白
UP