Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicInteger


            Message msg=new Message(null, sender, "hello");
            msg.putHeader(NAKACK_ID, hdr);
            boolean added=win.add(seqno, msg);

            if(added) {
                AtomicInteger val=map.get((long)seqno);
                val.incrementAndGet();
            }
        }
View Full Code Here


   * @param clientConn ClientConnection
   */
  public void clearAll(){
    this.localCache.clear();
    this.distributedCache.clear();
    this.totalRequests = new AtomicInteger();
    this.cacheHit = new AtomicInteger();
 
View Full Code Here

        stat.execute("set exclusive false");
        Connection conn2 = getConnection("exclusive");
        final Statement stat2 = conn2.createStatement();
        stat.execute("set exclusive true");
        final AtomicInteger state = new AtomicInteger(0);
        Task task = new Task() {
            public void call() throws SQLException {
                stat2.execute("select * from dual");
                if (state.get() != 1) {
                    new Error("unexpected state: " + state.get()).printStackTrace();
                }
            }
        };
        task.execute();
        state.set(1);
        stat.execute("set exclusive false");
        task.get();
        stat.execute("set exclusive true");
        conn.close();

View Full Code Here

     */
    private TaskEngine() {
        timer = new Timer("timer-whack", true);
        executor = Executors.newCachedThreadPool(new ThreadFactory() {

            final AtomicInteger threadNumber = new AtomicInteger(1);

            public Thread newThread(Runnable runnable) {
                // Use our own naming scheme for the threads.
                Thread thread = new Thread(Thread.currentThread().getThreadGroup(), runnable,
                                      "pool-whack" + threadNumber.getAndIncrement(), 0);
                // Make workers daemon threads.
                thread.setDaemon(true);
                if (thread.getPriority() != Thread.NORM_PRIORITY) {
                    thread.setPriority(Thread.NORM_PRIORITY);
                }
View Full Code Here

   {
      Converter converter = new AtomicIntegerConverter();
      assertEquals("", converter.getAsString(null, null, null));
      assertEquals("", converter.getAsString(null, null, ""));
      assertEquals(" ", converter.getAsString(null, null, " "));
      assertEquals("-1", converter.getAsString(null, null, new AtomicInteger(-1)));
      try
      {
         converter.getAsString(null, null, new Integer(0));
         fail("should only take atomic ints");
      }
View Full Code Here

        }
        int actualCapacity = HashUtils.nextPowerOfTwo(capacity);
        this._capacity = actualCapacity;
        this._capacityMask = actualCapacity - 1;
        this._array = new VolatileArray<NbGClockCacheEntry<K, V>>(actualCapacity);
        this._free = new AtomicInteger(actualCapacity);
        this._clockHand = CounterProvider.createIntCounter();
    }
View Full Code Here

    public BoundedTransferQueue(int capacity) {
        if(capacity < 1) {
            throw new IllegalArgumentException();
        }
        this._maxCapacity = capacity;
        this._remainingCapacity = new AtomicInteger(capacity);
        this._queue = new LinkedTransferQueue<E>();
    }
View Full Code Here

    private final AtomicInteger _used, _free; // as barriers

    public ConcurrentBoundedQueue(int capacity) {
        this._capacity = capacity;
        this._array = new AtomicReferenceArray<E>(capacity);
        this._readPtr = new AtomicInteger(0);
        this._writePtr = new AtomicInteger(0);
        this._used = new AtomicInteger(0);
        this._free = new AtomicInteger(capacity);
    }
View Full Code Here

    private final AtomicInteger refcount;
    private final MappedByteBuffer delegate;

    public CloseableMappedByteBuffer(MappedByteBuffer delegate) {
        this.refcount = new AtomicInteger(1);
        this.delegate = delegate;
    }
View Full Code Here

        return mock(typeToMock, typeToMock.getSimpleName());
    }

    @Override
    public <T> T mock(Class<T> typeToMock, String name) {
        names.putIfAbsent(name, new AtomicInteger());
        int count = names.get(name).getAndIncrement();
        T mock;
        if (count == 0) {
            mock = super.mock(typeToMock, name);
        } else {
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.