Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicInteger


        final ImmutableList<? extends ListenableFuture<? extends V>> futures,
        final boolean allMustSucceed, final Executor listenerExecutor) {
      this.futures = futures;
      this.values = Lists.newArrayListWithCapacity(futures.size());
      this.allMustSucceed = allMustSucceed;
      this.remaining = new AtomicInteger(futures.size());

      init(listenerExecutor);
    }
View Full Code Here


   protected ClusteredSession(ClusteredManager<O> manager)
   {
      super();
     
      // Initialize access count
      accessCount = ACTIVITY_CHECK ? new AtomicInteger() : null;
      this.firstAccess = true;
     
      setManager(manager);
      requireFullReplication();
   }
View Full Code Here

    */
   public void doBlocking(long sleep, int min, long idle, final boolean trackByTx) throws Exception
  
      failed = false;

      startedThreadCount = new AtomicInteger(0);
      connectionCount = new AtomicInteger(0);
      errorCount = new AtomicInteger(0);

      final int reps = 2; //getIterationCount();
      final int threadsPerConnection = 5; //getThreadCount();
      final long sleepTime = sleep;

View Full Code Here

    */
   public void doTimeout(int min, long idle, final boolean trackByTx) throws Exception
  
      failed = false;

      startedThreadCount = new AtomicInteger(0);

      final int reps = 1; //getIterationCount();
      final int threadsPerConnection = 1; //getThreadCount();

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
View Full Code Here

  }
   
 
  int perform(final int workers, final int loops, final int port, final Integer size) throws Exception {
   
    final AtomicInteger total = new AtomicInteger();
 

    running = 0;
    errors.clear();
   
    
    for (int i = 0; i < workers; i++) {
     
      Thread t = new Thread() {
        public void run() {
          running++;
         
          try {
            HttpClient httpClient = new HttpClient();
 
            for (int j = 0; j < loops; j++) {
              long start = System.currentTimeMillis();
              IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + port + "/"));

              long elapsed = (System.currentTimeMillis() - start);
              total.addAndGet((int) elapsed);
         
             
              Assert.assertEquals(200, response.getStatus());
              if (size != null) {
                Assert.assertEquals(size.intValue(), response.getBlockingBody().size());
              }

              //System.out.println(elapsed + " millis");
            }
           
          } catch (Exception e) {
            errors.add(e.toString());
          }

          running--;
        }
       
      };
      t.start();
    }
       
   

    do {
      QAUtil.sleep(100);
    } while (running > 0);

    return total.get();   
  }
View Full Code Here

    @Test
    public void testReconnect() throws Exception {
       
        IHttpRequestHandler hdl = new IHttpRequestHandler() {
           
            private AtomicInteger numRequests = new AtomicInteger(0);
           
            public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
               
                BodyDataSink ds = exchange.send(new HttpResponseHeader(200, "text/event-stream"));
               
                ds.write("data: " + numRequests.incrementAndGet() + "\n");
                ds.write("id: 4\n");
               
                if (numRequests.get() == 1) {
                    ds.destroy();
                } else {
                    ds.write("\n");
                }
            }
View Full Code Here

    }

    public void inc(final char c) {
        if (!Character.isLetter(c)) return;
        final Character cc = Character.toLowerCase(c);
        final AtomicInteger i = this.letter.get(cc);
        if (i == null) {
            this.letter.put(cc, new AtomicInteger(1));
        } else {
            i.incrementAndGet();
        }
        this.letters++;
    }
View Full Code Here

        score.getAndSet(newScore);
    }
   
    public void inc(final E obj, final int incrementScore) {
        if (obj == null) return;
        AtomicInteger score;
        synchronized (map) {
            score = this.map.get(obj);
            if (score == null) {
                this.map.put(obj, new AtomicInteger(incrementScore));
            }
        }
        score.addAndGet(incrementScore);
    }
View Full Code Here

    }
   
    public int delete(final E obj) {
        // deletes entry and returns previous score
        if (obj == null) return 0;
        final AtomicInteger score;
        synchronized (map) {
            score = map.remove(obj);
            if (score == null) return 0;
        }
        return score.intValue();
    }
View Full Code Here

        }
    }
   
    public int get(final E obj) {
        if (obj == null) return 0;
        final AtomicInteger score;
        synchronized (map) {
            score = map.get(obj);
        }
        if (score == null) return 0;
        return score.intValue();
    }
View Full Code Here

TOP

Related Classes of java.util.concurrent.atomic.AtomicInteger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.