#include #include #include void thread(int @c, char *@d, int @e, int @end); void threadmain(int, char**) { int @ic, @jc; char *@sc; int @end; chanset(ic, 0); chanset(jc, 0); chanset(sc, 0); chanset(end, 0); cothread(thread(ic, sc, jc, end), 4096); ic @= 5; ic @= 7; jc @= 20; sc @= "foobar"; sc @= "hello"; ic @= 10; end @= 0; } void thread(int @c, char *@d, int @e, int @end) { int i; char *s; for(;;) switch @{ alt @end: print("ending\n"); threadexitsall(nil); alt i = @c: alt i = @e: print("received from c or e: %d\n", i); break; alt s = @d: print("received from d: %s\n", s); print("again from d: %s\n", @d); break; } }