本文整理了Java中java.util.concurrent.locks.ReentrantReadWriteLock.writeLock
方法的一些代码示例,展示了ReentrantReadWriteLock.writeLock
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReentrantReadWriteLock.writeLock
方法的具体详情如下:
包路径:java.util.concurrent.locks.ReentrantReadWriteLock
类名称:ReentrantReadWriteLock
方法名:writeLock
暂无
代码示例来源:origin: alibaba/druid
public void clearWhiteList() {
lock.writeLock().lock();
try {
if (whiteList != null) {
whiteList = null;
}
} finally {
lock.writeLock().unlock();
}
}
代码示例来源:origin: apache/hbase
public FileArchiverNotifierImpl(
Connection conn, Configuration conf, FileSystem fs, TableName tn) {
this.conn = conn;
this.conf = conf;
this.fs = fs;
this.tn = tn;
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
readLock = lock.readLock();
writeLock = lock.writeLock();
}
代码示例来源:origin: apache/ignite
/**
* Release table lock.
*
* @param exclusive Exclusive flag.
*/
private void unlock(boolean exclusive) {
Lock l = exclusive ? lock.writeLock() : lock.readLock();
l.unlock();
}
代码示例来源:origin: alibaba/druid
public void clearBlackList() {
lock.writeLock().lock();
try {
if (blackList != null) {
blackList = null;
}
} finally {
lock.writeLock().unlock();
}
}
代码示例来源:origin: apache/incubator-pinot
public RealtimeInvertedIndexReader() {
ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
_readLock = readWriteLock.readLock();
_writeLock = readWriteLock.writeLock();
}
代码示例来源:origin: alibaba/druid
public void clearCache() {
lock.writeLock().lock();
try {
if (whiteList != null) {
whiteList = null;
}
if (blackList != null) {
blackList = null;
}
if (blackMergedList != null) {
blackMergedList = null;
}
} finally {
lock.writeLock().unlock();
}
}
代码示例来源:origin: apache/hbase
/**
* Closes the lock. This needs to be called in the finally block corresponding
* to the try block of #startRegionOperation
*/
private void closeBulkRegionOperation(){
if (lock.writeLock().isHeldByCurrentThread()) lock.writeLock().unlock();
else lock.readLock().unlock();
}
代码示例来源:origin: neo4j/neo4j
void flipTo( IndexProxy targetDelegate )
{
lock.writeLock().lock();
try
{
this.delegate = targetDelegate;
}
finally
{
lock.writeLock().unlock();
}
}
代码示例来源:origin: deeplearning4j/nd4j
protected static boolean isEligible(String message) {
try {
lock.readLock().lock();
if (hashSet.contains(message))
return false;
} finally {
lock.readLock().unlock();
}
try {
lock.writeLock().lock();
if (buffer.size() >= 100) {
String rem = buffer.remove();
hashSet.remove(rem);
}
buffer.add(message);
hashSet.add(message);
return true;
} finally {
lock.writeLock().unlock();
}
}
代码示例来源:origin: neo4j/neo4j
void setFlipTarget( IndexProxyFactory flipTarget )
{
lock.writeLock().lock();
try
{
this.flipTarget = flipTarget;
}
finally
{
lock.writeLock().unlock();
}
}
代码示例来源:origin: Alluxio/alluxio
/**
* Creates a new instance of {@link MountTable}.
*
* @param ufsManager the UFS manager
* @param rootMountInfo root mount info
*/
public MountTable(UfsManager ufsManager, MountInfo rootMountInfo) {
mState = new State(rootMountInfo);
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
mReadLock = lock.readLock();
mWriteLock = lock.writeLock();
mUfsManager = ufsManager;
}
代码示例来源:origin: neo4j/neo4j
/**
* This is private since it's called from the constructor.
*/
private void doBlockNewTransactions()
{
newTransactionsLock.writeLock().lock();
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Returns the Input/Output metadata for this step. By default, each step produces and accepts optional input.
*/
public StepIOMetaInterface getStepIOMeta( boolean createIfAbsent ) {
StepIOMetaInterface ioMeta = null;
lock.readLock().lock();
try {
if ( ( ioMetaVar == null ) && ( createIfAbsent ) ) {
ioMeta = new StepIOMeta( true, true, true, false, false, false );
lock.readLock().unlock();
lock.writeLock().lock();
try {
ioMetaVar = ioMeta;
lock.readLock().lock(); // downgrade to read lock before releasing write lock
} finally {
lock.writeLock().unlock();
}
} else {
ioMeta = ioMetaVar;
}
return ioMeta;
} finally {
lock.readLock().unlock();
}
}
代码示例来源:origin: prestodb/presto
private void closeCachedLookupSources()
{
lock.writeLock().lock();
try {
suppliedLookupSources.values().forEach(LookupSource::close);
suppliedLookupSources.clear();
}
finally {
lock.writeLock().unlock();
}
}
代码示例来源:origin: apache/shiro
public DefaultEventBus() {
this.registry = new LinkedHashMap<Object, Subscription>(); //not thread safe, so we need locks:
ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
this.registryReadLock = rwl.readLock();
this.registryWriteLock = rwl.writeLock();
this.eventListenerResolver = new AnnotationEventListenerResolver();
}
代码示例来源:origin: apache/zookeeper
private BitHashSet remove(String path) {
addRemovePathRWLock.writeLock().lock();
try {
return pathWatches.remove(path);
} finally {
addRemovePathRWLock.writeLock().unlock();
}
}
代码示例来源:origin: oracle/helidon
void subscribe() {
try {
subscriberLock.readLock().lock();
if (subscriber == null) {
subscriberLock.readLock().unlock();
subscriberLock.writeLock().lock();
try {
try {
if (subscriber == null) {
waitForSubscription(1, TimeUnit.SECONDS);
}
} finally {
subscriberLock.readLock().lock();
}
} finally {
subscriberLock.writeLock().unlock();
}
}
} finally {
subscriberLock.readLock().unlock();
}
}
代码示例来源:origin: neo4j/neo4j
void getWriteLock()
{
lock.writeLock().lock();
}
代码示例来源:origin: aws/aws-sdk-java
/**
* @param maxSize
* the maximum number of entries of the cache
*/
public FIFOCache(final int maxSize) {
if (maxSize < 1) {
throw new IllegalArgumentException("maxSize " + maxSize
+ " must be at least 1");
}
map = new BoundedLinkedHashMap<String, T>(maxSize);
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
rlock = lock.readLock();
wlock = lock.writeLock();
}
代码示例来源:origin: neo4j/neo4j
void releaseWriteLock()
{
lock.writeLock().unlock();
}
内容来源于网络,如有侵权,请联系作者删除!