C语言多线程编程一
c语言中有一个函数可以实现简单的多线程编程,它的函数原型为:
uintptr_t _beginthread( void( *start_address )( void * ), unsigned stack_size, void *arglist );
#define _CRT_SECURE_NO_WARNINGS //关闭安全检查 #include
#include
#include
#include
//使用多线程必须要加上的头文件 void thread_1(void *p){
//参数类型必须是void *p类型 MessageBoxA(NULL, "hello", "hello", 0); } int main(void){
for (int i = 0; i < 10; i++){
HANDLE handle1 = _beginthread(thread_1, 0, NULL); } //WaitForSingleObject(handle1, INFINITE); //加上这条语句就变成同步,否则就是异步。 system("pause"); return 0; }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/178921.html原文链接:https://javaforall.net
