Examples of AtomicIntegerArray


Examples of java.util.concurrent.atomic.AtomicIntegerArray

        }

        JSONArray array = new JSONArray();
        parser.parseArray(array);

        AtomicIntegerArray atomicArray = new AtomicIntegerArray(array.size());
        for (int i = 0; i < array.size(); ++i) {
            atomicArray.set(i, array.getInteger(i));
        }

        return (T) atomicArray;
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    final int THREADS=100;
    /**
     * Atomic array whose elements will be incremented and decremented
     */
    AtomicIntegerArray vector=new AtomicIntegerArray(1000);
    /*
     * An incrementer task
     */
    Incrementer incrementer=new Incrementer(vector);
    /*
     * A decrementer task
     */
    Decrementer decrementer=new Decrementer(vector);
   
    /*
     * Create and execute 100 incrementer and 100 decrementer tasks
     */
    Thread threadIncrementer[]=new Thread[THREADS];
    Thread threadDecrementer[]=new Thread[THREADS];
    for (int i=0; i<THREADS; i++) {
      threadIncrementer[i]=new Thread(incrementer);
      threadDecrementer[i]=new Thread(decrementer);
     
      threadIncrementer[i].start();
      threadDecrementer[i].start();
    }
   
    /*
     * Wait for the finalization of all the tasks
     */
    for (int i=0; i<THREADS; i++) {
      try {
        threadIncrementer[i].join();
        threadDecrementer[i].join();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
   
    /*
     * Write the elements different from 0
     */
    for (int i=0; i<vector.length(); i++) {
      if (vector.get(i)!=0) {
        System.out.println("Vector["+i+"] : "+vector.get(i));
      }
    }
   
    System.out.println("Main: End of the example");
  }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    Preconditions.checkNotNull(receiver);
    Preconditions.checkNotNull(parentAccounter);

    this.parentAccounter = parentAccounter;
    this.incoming = receiver.getProvidingEndpoints();
    this.remainders = new AtomicIntegerArray(incoming.size());
    this.oppositeMajorFragmentId = receiver.getOppositeMajorFragmentId();
    this.buffers = new RawBatchBuffer[minInputsRequired];
    this.context = context;
    try {
      String bufferClassName = context.getConfig().getString(ExecConstants.INCOMING_BUFFER_IMPL);
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    this.operator = operator;
    this.context = context;
    this.outGoingBatchCount = operator.getDestinations().size();
    this.popConfig = operator;
    this.statusHandler = new StatusHandler(sendCount, context);
    this.remainingReceivers = new AtomicIntegerArray(outGoingBatchCount);
    this.remaingReceiverCount = new AtomicInteger(outGoingBatchCount);
  }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

        JSON json = (JSON) JSON.parse(text);
        Assert.assertEquals("[214748364812,2147483648123]", json.toJSONString());
    }

    public void test_AtomicIntegerArray() throws Exception {
        AtomicIntegerArray array = new AtomicIntegerArray(3);
        array.set(0, 1);
        array.set(1, 2);
        array.set(2, 3);
        String text = JSON.toJSONString(array);
        Assert.assertEquals("[1,2,3]", text);
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    evictionLock = new ReentrantLock();
    evictionDeque = new LinkedDeque<>();
    drainStatus = new AtomicReference<>(IDLE);

    buffers = new Queue[NUMBER_OF_BUFFERS];
    bufferLengths = new AtomicIntegerArray(NUMBER_OF_BUFFERS);
    for (int i = 0; i < NUMBER_OF_BUFFERS; i++) {
      buffers[i] = new ConcurrentLinkedQueue<>();
    }

    // The notification queue and listener
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

        {
            capacity <<= 1;
        }
        if (capacity >= PARTITIONED_SIZE_THRESHOLD)
        {
            this.partitionedSize = new AtomicIntegerArray(SIZE_BUCKETS * 16); // we want 7 extra slots and 64 bytes for each slot. int is 4 bytes, so 64 bytes is 16 ints.
        }
        this.table = new AtomicReferenceArray(capacity + 1);
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

                if (oldTable.get(end) == null)
                {
                    oldTable.set(end, RESIZE_SENTINEL);
                    if (this.partitionedSize == null && newSize >= PARTITIONED_SIZE_THRESHOLD)
                    {
                        this.partitionedSize = new AtomicIntegerArray(SIZE_BUCKETS * 16);
                    }
                    resizeContainer = new ResizeContainer(new AtomicReferenceArray(newSize), oldTable.length() - 1);
                    oldTable.set(end, resizeContainer);
                    ownResize = true;
                }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

    public TestCallbackHandler1(int expectedSuccess, int expectedFailure) {
      this.expectedSuccess = expectedSuccess;
      this.expectedFailure = expectedFailure;

      actualStartSuccessArray = new AtomicIntegerArray(expectedSuccess);
      actualStartFailureArray = new AtomicIntegerArray(expectedFailure);
      actualQuerySuccessArray = new AtomicIntegerArray(expectedSuccess);
      actualQueryFailureArray = new AtomicIntegerArray(expectedFailure);
      actualStopSuccessArray = new AtomicIntegerArray(expectedSuccess);
      actualStopFailureArray = new AtomicIntegerArray(expectedFailure);
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicIntegerArray

                out.writeNull();
            }
            return;
        }

        AtomicIntegerArray array = (AtomicIntegerArray) object;
        int len = array.length();
        out.append('[');
        for (int i = 0; i < len; ++i) {
            int val = array.get(i);
            if (i != 0) {
                out.write(',');
            }
            out.writeInt(val);
        }
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.