Code example for ConcurrentMap

Methods: putIfAbsentremove

  public void register(final String service, ChatHandler handler)
    final DruidNode node = makeDruidNode(service);"Registering Eventhandler[%s]", service);
    if (handlers.putIfAbsent(service, handler) != null) {
      throw new ISE("handler already registered for service[%s]", service);
    try { 
    catch (Exception e) {
      log.warn(e, "Failed to register service[%s]", service);
      handlers.remove(service, handler);
  public void unregister(final String service)
Connect your IDE to all the code out there  Get Codota for Java