declare class Buffer attr buf first last n i meth init(N) buf:={NewArray 0 N-1 null} first:=0 last:=0 n:=N i:=0 end meth put(X) ... % wait until i0 % now remove an element: X=@buf.@first first:=(@first+1) mod @n i:=@i-1 end end