Examples of AtomicLong


Examples of java.util.concurrent.atomic.AtomicLong

     
      Pair<UUID, AtomicLong> value = targetAddressInfos.get(msg.getAddress());
     
      if (value == null)
      {
         targetAddressInfos.put(msg.getAddress(), new Pair<UUID,AtomicLong>(msg.getUserID(), new AtomicLong(1)));
      }
      else
      {
         value.a = msg.getUserID();
         value.b.incrementAndGet();
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

    final List<FacetAccessible> list1 = new ArrayList<FacetAccessible>(numSegs);
    for (int i = 0; i < numSegs; ++i) {
      list1.add(buildSubAccessible(fname1, i, fspec));
    }

    final AtomicLong timeCounter = new AtomicLong();
    Thread[] threads = new Thread[nThreads];
    for (int i = 0; i < threads.length; ++i) {
      threads[i] = new Thread(new Runnable() {

        @Override
        public void run() {

          for (int i = 0; i < numIters; ++i) {
            long start = System.nanoTime();
            long end = System.nanoTime();
            timeCounter.getAndAdd(end - start);
          }
        }

      });
    }

    for (Thread t : threads) {
      t.start();
    }

    for (Thread t : threads) {
      t.join();
    }

    System.out
        .println("average time: " + timeCounter.get() / numIters / nThreads / 1000000 + " ms");

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.