Java 8 ReentrantLock - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ReentrantLock class.

This code example shows how to use the following methods: lock, unlock
	private static ByteBuffer sSharedByteBuffer;
 
	public static int getSharedByteBufferByteCapacity() { 
		final int byteCapacity;
		try { 
			SharedMemoryVertexBufferObject.sSharedByteBufferLock.lock();
 
			final ByteBuffer sharedByteBuffer = SharedMemoryVertexBufferObject.sSharedByteBuffer;
			if(sharedByteBuffer == null) {
				byteCapacity = 0;
			} else { 
				byteCapacity = sharedByteBuffer.capacity();
			} 
		} finally { 
			SharedMemoryVertexBufferObject.sSharedByteBufferLock.unlock();
		} 
 
		return byteCapacity;
	} 
 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
	private volatile boolean shutdownInProgress;
 
 
	private final Lock flushLock = new ReentrantLock();
 
	private final Lock closeLock = new ReentrantLock();
 
 
	public ConcurrentWebSocketSessionDecorator(WebSocketSession delegate, int sendTimeLimit, int bufferSizeLimit) {
		super(delegate);
		this.sendTimeLimit = sendTimeLimit;
		this.bufferSizeLimit = bufferSizeLimit;
	} 
 
 
	public int getBufferSize() { 
		return this.bufferSize.get();
	} 
 
	public long getTimeSinceSendStarted() { 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isLocked, lock, unlock
package de.unisb.cs.st.javalanche.mutation.bytecodeMutations.replaceThreadCalls.classes; 
 
import java.util.concurrent.locks.ReentrantLock;
 
public class LockUnlockTEMPLATE { 
 
	int counter = 1;
 
	public boolean m1() { 
		ReentrantLock lock = new ReentrantLock();
		lock.lock(); 
		try { 
			counter++;
		} finally { 
			lock.unlock();
		} 
		return lock.isLocked();
	} 
} 

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: lock, unlock
        return offer(t);
    } 
 
    @Override 
    public boolean offer(T t) {
        lock.lock();
        try { 
            elements.add(t);
            notEmpty.signal();
            return true; 
        } finally { 
            lock.unlock();
        } 
    } 
 
    @Override 
    public T poll() { 
        lock.lock();
        try { 
            return dequeue(); 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
/** 
 * A MavenPublisher that restricts publishing to a single thread per Classloader that loads this class. 
 * This is required to prevent concurrent access to the Maven Ant Tasks, which hold static state. 
 */ 
public class StaticLockingMavenPublisher implements MavenPublisher { 
    private static final Lock STATIC_LOCK = new ReentrantLock();
    private final MavenPublisher delegate;
 
    public StaticLockingMavenPublisher(MavenPublisher delegate) {
        this.delegate = delegate;
    } 
 
    public void publish(MavenNormalizedPublication publication, MavenArtifactRepository artifactRepository) {
        STATIC_LOCK.lock();
        try { 
            delegate.publish(publication, artifactRepository);
        } finally { 
            STATIC_LOCK.unlock();
        } 
    } 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 ReentrantLock Questions & Answers:

See Code Examples for Java 8 ReentrantLock Methods: