3.1 pthread-1.01-0.flx
include "std/io/faio";
include "std/pthread/pchannels";
open Pthread;
print "Pthread spawning test"; endl;
proc thr (x:int) { print "Thread "; print x; endl; }
proc flx_main
{
print "Running main\n";
var chan = mk_pchannel[int]();
var dummy: int;
spawn_pthread { thr 1; write (chan,1); };
spawn_pthread { thr 2; write (chan,2); };
spawn_pthread { thr 3; write (chan,3); };
spawn_pthread { thr 4; write (chan,4); };
spawn_pthread { thr 5; write (chan,5); };
spawn_pthread { thr 6; write (chan,6); };
spawn_pthread { thr 7; write (chan,7); };
print "Spawned\n";
dummy = read chan;
print "joined "; print dummy; endl;
dummy = read chan;
print "joined "; print dummy; endl;
dummy = read chan;
print "joined "; print dummy; endl;
dummy = read chan;
print "joined "; print dummy; endl;
dummy = read chan;
print "joined "; print dummy; endl;
dummy = read chan;
print "joined "; print dummy; endl;
dummy = read chan;
print "joined "; print dummy; endl;
print "Joined all\n";
}
export proc flx_main of (1) as "flx_main";