Code example for Lock

Methods: newCondition

0
    private final Condition condition;
 
    public LockingCircularBuffer(int size, Lock lock) {
        super(size);
        this.lock = lock;
        condition = lock.newCondition();
    } 
 
    @Override 
    public void add(T item) {
        super.add(item);
        try { 
            lock.lock();
            condition.signalAll();
        } finally { 
            lock.unlock();
        } 
    } 
 
    @Override 
    public T take(AtomicLong idx) {