C语言如何创建线程(windows)系统中
的有关信息介绍如下:

下面为C语言调用WIN API实现创建线程:1,导入头文件2,声明实现方法DWORD WINAPI ThreadProc1( LPVOID lpParam ) {}3,在main()方法中调用 CreateThread(NULL,0 ,ThreadProc1,NULL,0,NULL);要注意的是主线程不能结束,如果主线程结束,则它的子线程也会被杀死。#include #include #includeDWORD WINAPI ThreadProc1( LPVOID lpParam ) {int i=0;time_t timer;while(1){timer=time(NULL);printf("The current time is: %s\n",asctime(localtime(&timer)));sleep(1); }} void main(){int i=0;//让主线程进入循环,主线程若退出,子线程1,2会被系统“杀死”//创建线程1CreateThread(NULL, // default security attributes0, // use default stack sizeThreadProc1, // thread functionNULL, // argument to thread function0, // use default creation flagsNULL); // returns the thread identifierfor(;;){;} }