{ Single producer consumer bounded buffer } { buffer has N slots } var InE, OutE: TEventCount; { Set up and initially 0 } { producer } var I: integer; begin while not terminated do begin OutE.Await(I - N); { insert item at I mod N } InE.Advance; Inc(I); end; end; { consumer } var I: integer; begin while not terminated do begin InE.Await(I); { remove item at i mod N } OutE.Advance; end; end;