📄 hello-solution.c
字号:
#include <stdio.h>#include <pthread.h>#define NUMTHREADS 4void *helloFunc(void *pArg) { int myNum = *((int *)pArg); printf("Hello from Thread #%d\n", myNum); }main() { pthread_t hThread[NUMTHREADS]; int tNum[NUMTHREADS]; for (int i = 0; i < NUMTHREADS; i++) { tNum[i] = i; pthread_create(&hThread[i], NULL, helloFunc, &tNum[i]); } for (int j = 0; j < NUMTHREADS; j++) pthread_join(hThread[j], NULL); return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -