9.2. test/pthread/pthread-1.02

Start felix section to test/pthread/pthread-1.02-0.flx[1 /1 ]
     1: #line 1580 "./lpsrc/flx_pthread.pak"
     2: #import <flx.flxh>
     3: include "pthread";
     4: include "flx_faio";
     5: open String;
     6: 
     7: print "Garbage collector world stop test"; endl;
     8: 
     9: var clock = Faio::mk_alarm_clock();
    10: 
    11: proc randprint(n:int)
    12: {
    13:   var i = 5;
    14:   print$ "Start Thread number "+str(n); endl;
    15:   whilst i > 0 do
    16:     var d = double_of$ Cstdlib::rand()%10;
    17:     if d == 0.0 do
    18:       print "ZERO FOUND -- collecting!"; endl;
    19:       collect;
    20:       print "collected!"; endl;
    21:     done;
    22:     print$ "Thread "+str n +" Sleep #"+str i+" for "+str d+" sec"; endl;
    23:     --i;
    24:     Faio::sleep (clock,d);
    25:   done;
    26:   print$ "Finish Thread number "+str(n); endl;
    27: }
    28: 
    29: Pthread::spawn_pthread { randprint(1); };
    30: Pthread::spawn_pthread { randprint(2); };
    31: Pthread::spawn_pthread { randprint(3); };
    32: Pthread::spawn_pthread { randprint(4); };
    33: Pthread::spawn_pthread { randprint(5); };
    34: 
    35: print "Mainline done!"; endl;
End felix section to test/pthread/pthread-1.02-0.flx[1]