class Barrier 
  def sync
    tmp, val = @ts.take([key, nil]) 
    @ts.write([key, val - 1]) 
    @ts.read([key, 0])
  end 
end
