AtomicInteger getAndAdd - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AtomicInteger getAndAdd method.

This code example shows how to use the following methods:get, getAndAdd, set
 
		return Double.longBitsToDouble(_reload());
	} 
 
	public static float nextFloat() { 
		int index = _index.getAndAdd(4);
 
		if ((index + 3) < _BUFFER_SIZE) {
			return BigEndianCodec.getFloat(_bytes, index);
		} 
 
		return Float.intBitsToFloat((int)_reload());
	} 
 
	public static int nextInt() { 
		int index = _index.getAndAdd(4);
 
		if ((index + 3) < _BUFFER_SIZE) {
			return BigEndianCodec.getInt(_bytes, index);
		} 

7
CodeRank
This code example shows how to use the following methods:getAndAdd, getAndSet
		} 
		doUpdates(); 
	} 
 
	private void doUpdates() { 
		int cnt = pendingUpdates.getAndSet(0);
		if (0 < cnt)
			pm.update(cnt);
	} 
 
	public void update(int completed) {
		int old = pendingUpdates.getAndAdd(completed);
		if (isMainThread()) 
			doUpdates(); 
		else if (old == 0)
			process.release();
	} 
 
	public boolean isCancelled() { 
		lock.lock();
5
CodeRank
This code example shows how to use the following methods:getAndAdd
	 * Gets a unique sequence number. 
	 * 
	 * @return the number 
	 */ 
	public static int get() { 
		return sequenceNumber.getAndAdd(2);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getAndAdd
		if (0 < cnt)
			pm.update(cnt);
	} 
 
	public void update(int completed) {
		if (0 == pendingUpdates.getAndAdd(completed))
			process.release();
	} 
 
	public boolean isCancelled() { 
		lock.lock();
		try { 
			return pm.isCancelled();
		} finally { 
			lock.unlock();
		} 
	} 
 
	public void endTask() { 
		if (!isMainThread()) 
5
CodeRank
This code example shows how to use the following methods:compareAndSet, getAndAdd
	 * @return 
	 */ 
	public static String getOrdersId(String uid)
	{ 
		StringBuffer sbstr = new StringBuffer();
		seq.compareAndSet(999, 0);
		sbstr.append("10");
		sbstr.append(getNowDateTimeString("yyyyMMddHHmmssSS"));
		sbstr.append(Integer.toString(seq.getAndAdd(1)));
		sbstr.append(uid);
		return sbstr.toString();
	} 
 
	public static void main(String[] args)
	{ 
		for (int i = 0; i < 10; i++)
		{ 
			String str = getOrdersId("81029203");
			System.out.println(str);
			System.out.println(str.length());
5
CodeRank
This code example shows how to use the following methods:getAndAdd, getAndSet
		} 
		doUpdates(); 
	} 
 
	private void doUpdates() { 
		int cnt = pendingUpdates.getAndSet(0);
		if (0 < cnt)
			pm.update(cnt);
	} 
 
	public void update(int completed) {
		int old = pendingUpdates.getAndAdd(completed);
		if (isMainThread()) 
			doUpdates(); 
		else if (old == 0)
			process.release();
	} 
 
	public boolean isCancelled() { 
		lock.lock();
4
CodeRank
This code example shows how to use the following methods:getAndAdd
    } 
 
    @Override 
    public int updateSendWindow(int delta)
    { 
        return sendWindow.getAndAdd(delta);
    } 
 
    @Override 
    public int updateRecvWindow(int delta)
    { 
        return recvWindow.getAndAdd(delta);
    } 
 
    @Override 
    public void close() 
    { 
        closeState.set(CloseState.CLOSED);
        onClose(); 
    } 
4
CodeRank
This code example shows how to use the following methods:getAndAdd
	 * Gets a unique sequence number. 
	 * 
	 * @return the number 
	 */ 
	public static int get() { 
		return sequenceNumber.getAndAdd(2);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getAndAdd
	} 
 
 
	public XorShift() 
	{ 
		this( (int) System.nanoTime() + seq.getAndAdd( 129 ) );
	} 
 
 
	public int next() 
	{ 
		x ^= x << 6;
		x ^= x >>> 21;
		x ^= (x << 7);
		return x;
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getAndAdd
 
    @Schedule(interval = 6000) 
    @Receive(uri = "${feed.uri}", properties = FEED.DONT_SPLIT_FEED) 
    public void readFeed(Feed feed) throws Exception
    { 
        count.getAndAdd(feed.getEntries().size());
    } 
 
    public int getCount() 
    { 
        return count.get();
    } 
} 
4
CodeRank
getAndAdd Method Overview
Atomically adds the given value to the current value.
See Code Examples for other Java 8 AtomicInteger Methods: