Libdill是一个C开发库,可以轻松用来编写结构化的并发程序。下面例子启动两个并发的worker函数打印Hello和World:
#iclude <libdill.h>#iclude <stdio.h>#iclude <stdlib.h>coroutie void worker(cost char *text) { while(1) { pritf("%s\", text); msleep(ow() + radom() % 500); }}it mai() { go(worker("Hello!")); go(worker("World!")); msleep(ow() + 5000); retur 0;}编译方法:
$ cc -ldill -o hello hello.c
评论