test02.c
来自「《unix网络编程第二卷》中的源代码」· C语言 代码 · 共 35 行
C
35 行
#include "unpthread.h"void *myfunc(void *ptr){ int val; printf("thread ID of myfunc: %d\n", pthread_self()); val = *((int *) ptr); printf("val = %d\n", val); sleep(10); val = *((int *) ptr); printf("val = %d\n", val);}intmain(int argc, char **argv){ pthread_t tid; int n, val; printf("thread ID of main: %d\n", pthread_self()); /* Let's verify that the value pointed to the thread's argument is modifiable */ val = 123; if ( (n = pthread_create(&tid, NULL, myfunc, &val)) != 0) errno = n, err_sys("pthread_create error"); sleep(5); val = 789; sleep(20); exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?