當前位置: 首頁>>代碼示例>>Java>>正文


Java ConcurrentHashMap.newKeySet方法代碼示例

本文整理匯總了Java中java.util.concurrent.ConcurrentHashMap.newKeySet方法的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentHashMap.newKeySet方法的具體用法?Java ConcurrentHashMap.newKeySet怎麽用?Java ConcurrentHashMap.newKeySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.ConcurrentHashMap的用法示例。


在下文中一共展示了ConcurrentHashMap.newKeySet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMobs

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
public Set<L2ControllableMobInstance> getMobs()
{
	if (_mobs == null)
	{
		_mobs = ConcurrentHashMap.newKeySet();
	}
	
	return _mobs;
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:10,代碼來源:MobGroup.java

示例2: QueueHandler

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
private QueueHandler(Queue queue) {
    this.queue = queue;
    unmodifiableQueueView = new UnmodifiableQueueWrapper(queue);
    // TODO: take message count from queue configuration
    this.redeliveryQueue = new MemQueueImpl(queue.getName(), 1000, false);
    this.consumers = ConcurrentHashMap.newKeySet();
    consumerIterator = new CyclicConsumerIterator();

}
 
開發者ID:wso2,項目名稱:message-broker,代碼行數:10,代碼來源:QueueHandler.java

示例3: Procedure

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
public Procedure(RegisterMessage registerMessage, long registrationId,
		boolean isDealerCallerIdentificationFeatureEnabled) {
	this.procedure = registerMessage.getProcedure();
	this.webSocketSessionId = registerMessage.getWebSocketSessionId();
	if (isDealerCallerIdentificationFeatureEnabled) {
		this.discloseCaller = registerMessage.isDiscloseCaller();
	}
	else {
		this.discloseCaller = false;
	}
	this.registrationId = registrationId;
	this.pendingInvocations = ConcurrentHashMap.newKeySet();
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:14,代碼來源:Procedure.java

示例4: Subscription

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
Subscription(String topic, MatchPolicy matchPolicy, long subscriptionId) {
	this.createdTimeMillis = System.currentTimeMillis();

	this.topicMatch = new DestinationMatch(topic, matchPolicy);

	this.subscriptionId = subscriptionId;
	this.subscribers = ConcurrentHashMap.newKeySet();
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:9,代碼來源:Subscription.java

示例5: addBlockedAbnormalTypes

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * Adds abnormal types to the blocked buff slot set.
 * @param blockedAbnormalTypes the blocked buff slot set to add
 */
public void addBlockedAbnormalTypes(Set<AbnormalType> blockedAbnormalTypes)
{
	if (_blockedAbnormalTypes == null)
	{
		synchronized (this)
		{
			if (_blockedAbnormalTypes == null)
			{
				_blockedAbnormalTypes = ConcurrentHashMap.newKeySet(blockedAbnormalTypes.size());
			}
		}
	}
	_blockedAbnormalTypes.addAll(blockedAbnormalTypes);
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:19,代碼來源:CharEffectList.java

示例6: registerUser

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session session) throws IOException {
Long lessonId = Long.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_LESSON_ID).get(0));
Set<Websocket> sessionWebsockets = PresenceWebsocketServer.websockets.get(lessonId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    PresenceWebsocketServer.websockets.put(lessonId, sessionWebsockets);
}
Websocket websocket = new Websocket(session);
sessionWebsockets.add(websocket);

Roster roster = PresenceWebsocketServer.rosters.get(lessonId);
if (roster == null) {
    boolean imEnabled = Boolean.valueOf(session.getRequestParameterMap().get("imEnabled").get(0));
    // build a new roster object
    roster = new Roster(lessonId, imEnabled);
    PresenceWebsocketServer.rosters.put(lessonId, roster);
}

new Thread(() -> {
    try {
	// websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually
	HibernateSessionManager.openSession();
	SendWorker.send(lessonId, websocket.nickName);
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();

if (PresenceWebsocketServer.log.isDebugEnabled()) {
    PresenceWebsocketServer.log
	    .debug("User " + websocket.nickName + " entered Presence Chat with lesson ID: " + lessonId);
}
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:38,代碼來源:PresenceWebsocketServer.java

示例7: registerUser

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session session) throws IOException {
Long toolSessionId = Long
	.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Websocket> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
}
final Set<Websocket> finalSessionWebsockets = sessionWebsockets;

String userName = session.getUserPrincipal().getName();
new Thread(() -> {
    try {
	// websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually
	HibernateSessionManager.openSession();
	ChatUser chatUser = LearningWebsocketServer.getChatService().getUserByLoginNameAndSessionId(userName,
		toolSessionId);
	Websocket websocket = new Websocket(session, chatUser.getNickname(), chatUser.getUserId(), getPortraitId(chatUser.getUserId()));
	finalSessionWebsockets.add(websocket);

	// update the chat window immediatelly
	SendWorker.send(toolSessionId);

	if (LearningWebsocketServer.log.isDebugEnabled()) {
	    LearningWebsocketServer.log
		    .debug("User " + userName + " entered Chat with toolSessionId: " + toolSessionId);
	}
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:37,代碼來源:LearningWebsocketServer.java

示例8: registerUser

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session websocket) throws JSONException, IOException {
Long toolSessionId = Long
	.valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Session> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);

    Map<Long, Map<Long, Boolean>> sessionCache = new TreeMap<>();
    LearningWebsocketServer.cache.put(toolSessionId, sessionCache);
}
sessionWebsockets.add(websocket);

if (LearningWebsocketServer.log.isDebugEnabled()) {
    LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName()
	    + " entered Scratchie with toolSessionId: " + toolSessionId);
}
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:LearningWebsocketServer.java

示例9: registerUser

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session websocket) throws JSONException, IOException {
Long toolSessionId = Long
	.valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Session> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
}
sessionWebsockets.add(websocket);

if (LearningWebsocketServer.log.isDebugEnabled()) {
    LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName()
	    + " entered Scribe with toolSessionId: " + toolSessionId);
}

new Thread(() -> {
    try {
	HibernateSessionManager.openSession();
	SendWorker.send(toolSessionId, websocket);
    } catch (Exception e) {
	log.error("Error while sending messages", e);
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:LearningWebsocketServer.java

示例10: createsNewRule

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
@Test
public void createsNewRule() {
    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = getRuleSetBuilder();

    final DriverCache cache = new DriverCache();
    final Set<ValueGroup> groups = ConcurrentHashMap.newKeySet();
    final ValueGroup group = new ValueGroup("CMEGroup", Arrays.asList("CME", "CBOT"));
    groups.add(group);
    RuleSetBuilder.addValueGroupsToDriverCache(cache, groups);

    ruleSetBuilder.with(RuleSetBuilder::setCache, cache);
    ruleSetBuilder.with(RuleSetBuilder::groups, groups);
    this.ruleSet = ruleSetBuilder.build();

    this.builder = RuleChangeBuilder.creator(this.ruleSet, new UUID(0, 9));
    this.builder.with(RuleChangeBuilder::input,
            Arrays.asList("VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId()));
    this.builder.with(RuleChangeBuilder::output, Collections.singletonMap("Rate", "2.0"));
    this.builder.with(RuleChangeBuilder::changeRange,
            new DateRange(NOW.minus(Period.ofWeeks(1)), NOW.plus(Period.ofWeeks(1))));
    final List<RuleChange> ruleChanges = this.builder.build();
    assertThat(ruleChanges, hasSize(1));

    final RuleChange change = ruleChanges.get(0);
    assertEquals(Type.NEW, change.getType());

    assertRuleChange(change, Type.NEW, null, new UUID(0, 9),
            new String[]{"VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId().toString()},
            Collections.singletonMap("Rate", "2.0"), NOW.minus(Period.ofWeeks(1)),
            NOW.plus(Period.ofWeeks(1)));

    final List<String> driverValues =
            Arrays.stream(change.getRule().getDrivers()).map(InputDriver::toString).collect(Collectors.toList());
    assertThat(driverValues, contains("VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId()));
}
 
開發者ID:jpmorganchase,項目名稱:swblocks-decisiontree,代碼行數:36,代碼來源:RuleChangeBuilderTest.java

示例11: getStatusListener

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * Return the list of L2Character that must be informed of HP/MP updates of this L2Character.<br>
 * <B><U>Concept</U>:</B><br>
 * Each L2Character owns a list called <B>_statusListener</B> that contains all L2PcInstance to inform of HP/MP updates.<br>
 * Players who must be informed are players that target this L2Character.<br>
 * When a RegenTask is in progress sever just need to go through this list to send Server->Client packet StatusUpdate.
 * @return The list of L2Character to inform or null if empty
 */
public final Set<L2Character> getStatusListener()
{
	if (_StatusListener == null)
	{
		_StatusListener = ConcurrentHashMap.newKeySet();
	}
	return _StatusListener;
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:17,代碼來源:CharStatus.java

示例12: getAttackByList

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * @return a list of L2Character that attacked.
 */
public final Set<WeakReference<L2Character>> getAttackByList()
{
	if (_attackByList == null)
	{
		synchronized (this)
		{
			if (_attackByList == null)
			{
				_attackByList = ConcurrentHashMap.newKeySet();
			}
		}
	}
	return _attackByList;
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:18,代碼來源:L2Character.java

示例13: addToWaitingList

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
public void addToWaitingList(L2PcInstance player)
{
	if (_waitingList == null)
	{
		synchronized (this)
		{
			if (_waitingList == null)
			{
				_waitingList = ConcurrentHashMap.newKeySet(1);
			}
		}
	}
	_waitingList.add(player);
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:15,代碼來源:MatchingRoomManager.java

示例14: populatedSet

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
static Set<Integer> populatedSet(int n) {
    Set<Integer> a = ConcurrentHashMap.<Integer>newKeySet();
    assertTrue(a.isEmpty());
    for (int i = 0; i < n; i++)
        assertTrue(a.add(i));
    assertEquals(n == 0, a.isEmpty());
    assertEquals(n, a.size());
    return a;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:ConcurrentHashMap8Test.java

示例15: JsonBackedNotifiersRepositoryImpl

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
@Autowired
public JsonBackedNotifiersRepositoryImpl(@Value("${notifiers.file}") File notifierFile, ObjectMapper objectMapper) throws IOException {
    this.notifierSet = ConcurrentHashMap.newKeySet();
    this.notifierFile = notifierFile;
    this.objectMapper = objectMapper;


    if (notifierFile.exists()) {
        loadFromFile();
    } else {
        notifierFile.createNewFile();
        writeToFile();
    }
}
 
開發者ID:gilles-stragier,項目名稱:quickmon,代碼行數:15,代碼來源:JsonBackedNotifiersRepositoryImpl.java


注:本文中的java.util.concurrent.ConcurrentHashMap.newKeySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。