#include <windows.h>
#include <iostream.h>
DWORD WINAPI Fun1Proc(LPVOID lpParameter);
void main()
{
int index=0;
HANDLE hThread;
hThread=CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);
CloseHandle(hThread);
while (index++<100)
{
cout<<"main thread is running"<<endl;
}
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
int index=0;
while (index<100)
{
cout<<"thread1 is running"<<endl;
}
return 0;
}
和上一个帖子中的程序差别不大,在main函数和fun1proc中加入循环,示例时间片轮转的运行