Open hiroyuki-sato opened 4 years ago
#include <dispatch/dispatch.h> #include <stdio.h> void func(){ dispatch_queue_t queue = dispatch_queue_create("org.openucx", DISPATCH_QUEUE_CONCURRENT); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), queue, ^{ printf("called 3sec after\n"); }); sleep(3); printf("call this part first\n"); dispatch_release(queue); } int main(){ int i; func(); for(i=0; i<5;i++){ printf("%d\n",i); sleep(1); } }
GCD (Grand Central Dispatch) - Dispatch Queue でマルチスレッドプログラミング
GCD (Grand Central Dispatch) - Dispatch Queue でマルチスレッドプログラミング