Code example for Exchanger

Methods: exchange

0
 
      public Agent enter(Agent visitor) throws InterruptedException {
         if (meetingsLeft.get() < 0) {
            return null; 
         } 
         Agent agent = room.exchange(visitor);
         latch.countDown();
         if (meetingsLeft.decrementAndGet() < 0) {
            return null; 
         } 
         return agent;
      } 
 
   } 
 
   static class Agent { 
      final int name;
      final Color color;
 
      Agent(Creature creature) {
Contextual code suggestions in your IDE  Get Codota for Java