当前位置: 首页>>代码示例>>Java>>正文


Java ReentrantReadWriteLock.readLock方法代码示例

本文整理汇总了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>();  
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:RMNodeImpl.java

示例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();
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:11,代码来源:RowStoreAVLMemory.java

示例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();
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:RowStoreAVLDisk.java

示例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();
	}
}
 
开发者ID:jeci-sarl,项目名称:alfresco-object-storage-connectors,代码行数:15,代码来源:ObjectStorageContentStore.java

示例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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestIdReadWriteLock.java

示例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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:AbstractYarnScheduler.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:QueueCapacities.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:34,代码来源:CycleDetectingLockFactoryTest.java

示例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();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:15,代码来源:FifoCache.java

示例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 ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:ProxyAknService.java

示例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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:RMStateStore.java

示例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 ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:16,代码来源:EventInjectorImpl.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:RMAppAttemptMetrics.java

示例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();
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:9,代码来源:AlfrescoKeyStoreImpl.java

示例15: ReadWriteLockExecuter

import java.util.concurrent.locks.ReentrantReadWriteLock; //导入方法依赖的package包/类
/**
 * Default constructor
 */
public ReadWriteLockExecuter()
{
    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    readLock = lock.readLock();
    writeLock = lock.writeLock();
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:10,代码来源:ReadWriteLockExecuter.java


注:本文中的java.util.concurrent.locks.ReentrantReadWriteLock.readLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。