Code example for AtomicInteger

Methods: getAndAdd

0
   private static final ThreadLocal<String> threadTcpStartPort = new ThreadLocal<String>() {
      private final AtomicInteger uniqueAddr = new AtomicInteger(7900); 
 
      @Override 
      protected String initialValue() { 
         return String.valueOf(uniqueAddr.getAndAdd(50)); 
      } 
   }; 
 
   /** 
    * Holds unique mcast_addr for each thread used for JGroups channel construction. 
    */ 
   private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>() {
      private final AtomicInteger uniqueAddr = new AtomicInteger(11); 
 
      @Override 
      protected String initialValue() { 
         return "228.10.10." + uniqueAddr.getAndIncrement(); 
      } 
   };