Example
The following example launches two concurrent worker functions that print "Hello!" or "World!", respectively, at random intervals. The program runs for five seconds and then it shuts down.
#include <libdill.h>
#include <stdio.h>
#include <stdlib.h>
coroutine void worker(const char *text) {
while(1) {
printf("%s\n", text);
msleep(now() + random() % 500);
}
}
int main() {
go(worker("Hello!"));
go(worker("World!"));
msleep(now() + 5000);
return 0;
}