self2.c
来自「cygwin, 著名的在win32下模拟unix操作系统的东东」· C语言 代码 · 共 47 行
C
47 行
/* * self2.c * * Test for pthread_self(). * * Depends on API functions: * pthread_create() * pthread_self() * * Implicitly depends on: * pthread_getspecific() * pthread_setspecific() */#include "test.h"#include <string.h>static pthread_t me;void *entry(void * arg){ me = pthread_self(); return arg;}intmain(){ pthread_t t; assert(pthread_create(&t, NULL, entry, NULL) == 0); Sleep(2000); /* * Not much more we can do here but bytewise compare t with * what pthread_self returned. */ assert(t == me); assert(memcmp((const void *) t, (const void *) me, sizeof t) == 0); /* Success. */ return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?