pthread.c
来自「linux下的多线程调试工具」· C语言 代码 · 共 34 行
C
34 行
#define _XOPEN_SOURCE 600#include <pthread.h>#include <stdio.h>#include <time.h>#include "alias.h"struct timespec wait = {0, 10000000};struct timespec longwait = {0, 30000000};struct timespec rem;#define WAIT nanosleep (&wait, &rem)#define LONGWAIT nanosleep (&longwait, &rem)FILE *fd;void *func () { new_thread_alias (fd, "func"); WAIT;}int main () { pthread_t thread; fd = alias_init ("alias"); new_thread_alias (fd, "main"); pthread_create (&thread, NULL, func, NULL); pthread_cancel (&thread); pthread_join (thread, NULL); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?