procmodel.c
来自「Solaris下进程编程源码,sun公司培训用例」· C语言 代码 · 共 40 行
C
40 行
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <pthread.h>void* thr_fn1(void*);void* thr_fn2(void*);int main(){ pthread_t tid; if (pthread_create(&tid, NULL, thr_fn1, NULL) != 0) exit(-1); if (pthread_create(&tid, NULL, thr_fn2, NULL) != 0) exit(-1); while (1) { sleep(1); printf("Thread %d is running...\n", pthread_self()); }}void* thr_fn1(void* args){ while (1) { sleep(2); printf("Thread %d is running...\n", pthread_self()); }}void* thr_fn2(void* args){ while (1) { sleep(3); printf("Thread %d is running...\n", pthread_self()); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?