⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 once1.c

📁 cygwin, 著名的在win32下模拟unix操作系统的东东
💻 C
字号:
/* * once1.c * * Create a static pthread_once and test that it calls myfunc once. * * Depends on API functions: *	pthread_once() *	pthread_create() */#include "test.h"pthread_once_t once = PTHREAD_ONCE_INIT;static int washere = 0;voidmyfunc(void){  washere++;}void *mythread(void * arg){   assert(pthread_once(&once, myfunc) == 0);   return 0;}intmain(){  pthread_t t1, t2;    assert(pthread_create(&t1, NULL, mythread, NULL) == 0);  assert(pthread_create(&t2, NULL, mythread, NULL) == 0);  Sleep(2000);  assert(washere == 1);  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -