! Create/delete sub-process demo program

%option "-nocheck-nodiag"
%include "mouse.inc"
%begin
%label l1,l2
%owninteger i=0,j=0              { OWN because accessed by subprocesses
%ownrecord(pcbfm)%name sub1,sub2

{if you take the next line out it will not work as smoothly
! @16_41c %routine printsymbol(%integer k)

{if you take the next line out it won't work at all at first
{because the default time slice size is infinite, here we set
{it to 5 ticks of 10ms each.
  set time slice size(5)
  sub1 == create subprocess(8000,addr(l1),"One")
  sub2 == create subprocess(8000,addr(l2),"Two")

{the 2 subprocesses are now ready and will
{start as soon as our time slice expires.
  printsymbol('0') %until i+j=5000

{when i and j have both reached 2500 they have finished
  newline
  %stop

l1: printsymbol('1') %for i = 1,1,2500
  delete subprocess(sub1)

l2: printsymbol('2') %for j = 1,1,2500
  delete subprocess(sub2)
%end
