本文整理汇总了Java中java.util.concurrent.locks.ReentrantReadWriteLock.readLock方法的典型用法代码示例。如果您正苦于以下问题:Java ReentrantReadWriteLock.readLock方法的具体用法?Java ReentrantReadWriteLock.readLock怎么用?Java ReentrantReadWriteLock.readLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.locks.ReentrantReadWriteLock
的用法示例。
在下文中一共展示了ReentrantReadWriteLock.readLock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RMNodeImpl
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public RMNodeImpl(NodeId nodeId, RMContext context, String hostName,
int cmPort, int httpPort, Node node, Resource capability, String nodeManagerVersion) {
this.nodeId = nodeId;
this.context = context;
this.hostName = hostName;
this.commandPort = cmPort;
this.httpPort = httpPort;
this.totalCapability = capability;
this.nodeAddress = hostName + ":" + cmPort;
this.httpAddress = hostName + ":" + httpPort;
this.node = node;
this.healthReport = "Healthy";
this.lastHealthReportTime = System.currentTimeMillis();
this.nodeManagerVersion = nodeManagerVersion;
this.latestNodeHeartBeatResponse.setResponseId(0);
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
this.readLock = lock.readLock();
this.writeLock = lock.writeLock();
this.stateMachine = stateMachineFactory.make(this);
this.nodeUpdateQueue = new ConcurrentLinkedQueue<UpdatedContainerInfo>();
}
示例2: RowStoreAVLMemory
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public RowStoreAVLMemory(Table table) {
this.database = table.database;
this.table = table;
this.indexList = table.getIndexList();
this.accessorList = new CachedObject[indexList.length];
lock = new ReentrantReadWriteLock();
readLock = lock.readLock();
writeLock = lock.writeLock();
}
示例3: RowStoreAVLDisk
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public RowStoreAVLDisk(DataFileCache cache, Table table) {
this(table);
this.cache = cache;
rowOut = cache.rowOut.duplicate();
cache.adjustStoreCount(1);
largeData = database.logger.propLargeData;
tableSpace = cache.spaceManager.getTableSpace(table.getSpaceID());
lock = new ReentrantReadWriteLock();
readLock = lock.readLock();
writeLock = lock.writeLock();
}
示例4: delete
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
@Override
public boolean delete(String contentUrl) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Delete %s", contentUrl));
}
ReentrantReadWriteLock readWriteLock = readWriteLock(contentUrl);
ReadLock readLock = readWriteLock.readLock();
readLock.lock();
try {
return this.objectStorageService.delete(contentUrl);
} finally {
readLock.unlock();
}
}
示例5: call
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
@Override
public Boolean call() throws Exception {
Thread.currentThread().setName(clientId);
Random rand = new Random();
long endTime = System.currentTimeMillis() + NUM_SECONDS * 1000;
while (System.currentTimeMillis() < endTime) {
long id = rand.nextInt(NUM_IDS);
boolean readLock = rand.nextBoolean();
ReentrantReadWriteLock readWriteLock = idLock.getLock(id);
Lock lock = readLock ? readWriteLock.readLock() : readWriteLock.writeLock();
try {
lock.lock();
int sleepMs = 1 + rand.nextInt(4);
String owner = idOwner.get(id);
if (owner != null && LOG.isDebugEnabled()) {
LOG.debug((readLock ? "Read" : "Write") + "lock of Id " + id + " already taken by "
+ owner + ", we are " + clientId);
}
idOwner.put(id, clientId);
Thread.sleep(sleepMs);
idOwner.remove(id);
} finally {
lock.unlock();
if (LOG.isDebugEnabled()) {
LOG.debug("Release " + (readLock ? "Read" : "Write") + " lock of Id" + id + ", we are "
+ clientId);
}
}
}
return true;
}
示例6: AbstractYarnScheduler
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
/**
* Construct the service.
*
* @param name service name
*/
public AbstractYarnScheduler(String name) {
super(name);
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
this.maxAllocReadLock = lock.readLock();
this.maxAllocWriteLock = lock.writeLock();
}
示例7: QueueCapacities
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public QueueCapacities(boolean isRoot) {
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
readLock = lock.readLock();
writeLock = lock.writeLock();
capacitiesMap = new HashMap<String, Capacities>();
this.isRoot = isRoot;
}
示例8: setUp
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
CycleDetectingLockFactory factory =
CycleDetectingLockFactory.newInstance(Policies.THROW);
lockA = factory.newReentrantLock("LockA");
lockB = factory.newReentrantLock("LockB");
lockC = factory.newReentrantLock("LockC");
ReentrantReadWriteLock readWriteLockA =
factory.newReentrantReadWriteLock("ReadWriteA");
ReentrantReadWriteLock readWriteLockB =
factory.newReentrantReadWriteLock("ReadWriteB");
ReentrantReadWriteLock readWriteLockC =
factory.newReentrantReadWriteLock("ReadWriteC");
readLockA = readWriteLockA.readLock();
readLockB = readWriteLockB.readLock();
readLockC = readWriteLockC.readLock();
writeLockA = readWriteLockA.writeLock();
writeLockB = readWriteLockB.writeLock();
writeLockC = readWriteLockC.writeLock();
CycleDetectingLockFactory.WithExplicitOrdering<MyOrder> factory2 =
newInstanceWithExplicitOrdering(MyOrder.class, Policies.THROW);
lock1 = factory2.newReentrantLock(MyOrder.FIRST);
lock2 = factory2.newReentrantLock(MyOrder.SECOND);
lock3 = factory2.newReentrantLock(MyOrder.THIRD);
CycleDetectingLockFactory.WithExplicitOrdering<OtherOrder> factory3 =
newInstanceWithExplicitOrdering(OtherOrder.class, Policies.THROW);
lock01 = factory3.newReentrantLock(OtherOrder.FIRST);
lock02 = factory3.newReentrantLock(OtherOrder.SECOND);
lock03 = factory3.newReentrantLock(OtherOrder.THIRD);
}
示例9: FifoCache
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
/**
* @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();
}
示例10: ProxyAknService
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public ProxyAknService ( final BundleContext context )
{
this.context = context;
final ReentrantReadWriteLock rw = new ReentrantReadWriteLock ();
this.readLock = rw.readLock ();
this.writeLock = rw.writeLock ();
}
示例11: RMStateStore
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public RMStateStore() {
super(RMStateStore.class.getName());
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
this.readLock = lock.readLock();
this.writeLock = lock.writeLock();
stateMachine = stateMachineFactory.make(this);
}
示例12: EventInjectorImpl
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public EventInjectorImpl ( final BundleContext context, final EventMonitorEvaluator evaluator )
{
this.context = context;
final ReentrantReadWriteLock rw = new ReentrantReadWriteLock ();
this.readLock = rw.readLock ();
this.writeLock = rw.writeLock ();
this.evaluator = evaluator;
this.executor = new ExportedExecutorService ( "org.eclipse.scada.ae.server.injector", 1, 1, 1, TimeUnit.MINUTES );
this.factoryTracker = new EventHandlerFactoryTracker ( context, this.factoryListener );
addDefault ();
}
示例13: RMAppAttemptMetrics
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public RMAppAttemptMetrics(ApplicationAttemptId attemptId,
RMContext rmContext) {
this.attemptId = attemptId;
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
this.readLock = lock.readLock();
this.writeLock = lock.writeLock();
this.rmContext = rmContext;
}
示例14: AlfrescoKeyStoreImpl
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
public AlfrescoKeyStoreImpl()
{
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
writeLock = lock.writeLock();
readLock = lock.readLock();
this.keys = new KeyMap();
this.backupKeys = new KeyMap();
}
示例15: ReadWriteLockExecuter
import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
/**
* Default constructor
*/
public ReadWriteLockExecuter()
{
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
readLock = lock.readLock();
writeLock = lock.writeLock();
}