Java AtomicInteger getLock()

Here you can find the source of getLock()

Description

get Lock

License

Apache License

Declaration

public static Object getLock() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.atomic.AtomicInteger;

public class Main {
    private static Object[] LOCK = { new Object(), new Object() };
    private static AtomicInteger lockIndex = new AtomicInteger(0);

    public static Object getLock() {
        int index = lockIndex.incrementAndGet();
        if (index >= LOCK.length) {
            index = 0;/*  www.ja  va 2  s  .  c  om*/
            lockIndex.set(index);
        }
        return LOCK[index];
    }
}

Related

  1. getFailedMiddlePartNumbers(PartListing partListing)
  2. getGetPendingWrTransaction()
  3. getGuid(Object clazz)
  4. getId()
  5. getInstanceCounter(String name)
  6. getNextCounter(AtomicInteger counter)
  7. getNextId()
  8. getNextTempQueueName()
  9. getPortOffset()