const RendezvousC <- monitor class RendezvousC
  var count : Integer <- 0
  var waiters : Condition <- Condition.create
  export operation rendezvous
    if count == 0 then
      count <- 1
      wait waiters
    else
      count <- 0
      signal waiters
    end if
  end rendezvous
end RendezvousC

const Prog1 <- object Prog1
  process
    var i: Integer
    var worker: Any
    var home: Node <-locate self
    var r: RendezvousC <- RendezvousC.create
    for (i <- 1: i <= 2 : i <- i+1)
      worker <- object W
        process
          home$stdout.PutString[home.gettimeofday.asDate || ": "]
          home$stdout.PutString["Worker no " || i.asString || " starting\n"]
          (locate self).Delay[Time.create[5*i, 1]] 
          home$stdout.PutString[home.gettimeofday.asDate || ": "]
          home$stdout.PutString["Worker no " || i.asString || " rendevousing\n"]
          r.rendezvous[]
          home$stdout.PutString[home.gettimeofday.asDate || ": "]
          home$stdout.PutString["Worker no " || i.asString || " back from rendezvous\n"]
        end process
      end W
    end for
  end process
end Prog1
