Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicInteger.compareAndSet()


    {
      int i = localAtomicInteger.get();
      if (i < paramInt)
        return false;
      int j = i - paramInt;
      if (localAtomicInteger.compareAndSet(i, j))
      {
        if (j == 0)
          this.countMap.remove(paramObject, localAtomicInteger);
        return true;
      }
View Full Code Here


    }
  }

  public static void main(String[] args) {
    AtomicInteger integer = new AtomicInteger(0);
    boolean ret = integer.compareAndSet(1, 2);
    System.out.println("ret = " + ret);
    System.out.println("integer.get() = " + integer.get());
   
    class s {
    ConcurrentCachedValue<Void, Map<String, String>> field = new ConcurrentCachedValue<Void, Map<String, String>>(new Computable<Map<String, String>>() {
View Full Code Here

    }

    @Test
    public void compareAndSet() throws Exception {
        AtomicInteger value = new AtomicInteger();
        assert value.compareAndSet(0, 10);
        assert value.get() == 10;

        assert !value.compareAndSet(20, 30);
        assert value.get() == 10;
    }
View Full Code Here

    public void compareAndSet() throws Exception {
        AtomicInteger value = new AtomicInteger();
        assert value.compareAndSet(0, 10);
        assert value.get() == 10;

        assert !value.compareAndSet(20, 30);
        assert value.get() == 10;
    }

    @Test
    public void weakCompareAndSet() throws Exception {
View Full Code Here

        @Override
        protected void _processEvent(InjectionEventI event, Object... args) {
          if (event == InjectionEvent.DATANODE_BEFORE_RECOVERBLOCK) {
            DataNode dn = (DataNode) args[0];
            int dnPort = dn.getPort();
            hangDnPort.compareAndSet(-1, dnPort);
            if (hangDnPort.get() == dnPort) {
              try {
                System.out.println("SLEEPING DN PORT: " + dnPort
                    + " IPC PORT: " + dn.getRpcPort());
                Thread.sleep(60000);
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.