Even with ConcurrentHashMap we want to synchronize here, so newly created Simons can be fully
set up with {@link Callback#onSimonCreated(Simon)}. ConcurrentHashMap still works fine for
listing Simons, etc.
503393
private synchronized Simon createSimon(String name, Class<? extends AbstractSimon> simonClass) {
		AbstractSimon simon = allSimons.get(name);
		if (simon == null) {
			SimonUtils.validateSimonName(name);
			simon = newSimon(name, simonClass);
		} else if (simon instanceof UnknownSimon) {
			simon = replaceUnknownSimon(simon, simonClass);
		}
		callback.onSimonCreated(simon);
		return simon;
	}
930407
public void sync() throws MarkLogicSesameException {
		if(WRITE_CACHE_ENABLED && timerWriteCache != null)
			timerWriteCache.forceRun();
		if(DELETE_CACHE_ENABLED && timerDeleteCache != null)
			timerDeleteCache.forceRun();
	}
1152116
private ConcurrentHashMap<JobVertexID, TaskStateStats> createEmptyTaskStateStatsMap() {
		ConcurrentHashMap<JobVertexID, TaskStateStats> taskStatsMap = new ConcurrentHashMap<>(jobVertices.size());
		for (ExecutionJobVertex vertex : jobVertices) {
			TaskStateStats taskStats = new TaskStateStats(vertex.getJobVertexId(), vertex.getParallelism());
			taskStatsMap.put(vertex.getJobVertexId(), taskStats);
		}
		return taskStatsMap;
	}
553478
@Override
    public java.util.concurrent.Future<ListSubscriptionsByTopicResult> listSubscriptionsByTopicAsync(String topicArn,
            com.amazonaws.handlers.AsyncHandler<ListSubscriptionsByTopicRequest, ListSubscriptionsByTopicResult> asyncHandler) {

        return listSubscriptionsByTopicAsync(new ListSubscriptionsByTopicRequest().withTopicArn(topicArn), asyncHandler);
    }
632126
@SuppressWarnings({ "unchecked" })
    /* package */<T> HystrixCachedObservable<T> putIfAbsent(String cacheKey, HystrixCachedObservable<T> f) {
        ValueCacheKey key = getRequestCacheKey(cacheKey);
        if (key != null) {
            /* look for the stored value */
            ConcurrentHashMap<ValueCacheKey, HystrixCachedObservable<?>> cacheInstance = requestVariableForCache.get(concurrencyStrategy);
            if (cacheInstance == null) {
                throw new IllegalStateException("Request caching is not available. Maybe you need to initialize the HystrixRequestContext?");
            }
            HystrixCachedObservable<T> alreadySet = (HystrixCachedObservable<T>) cacheInstance.putIfAbsent(key, f);
            if (alreadySet != null) {
                // someone beat us so we didn't cache this
                return alreadySet;
            }
        }
        // we either set it in the cache or do not have a cache key
        return null;
    }
1290471
@Override
    public java.util.concurrent.Future<ListSAMLProvidersResult> listSAMLProvidersAsync(
            com.amazonaws.handlers.AsyncHandler<ListSAMLProvidersRequest, ListSAMLProvidersResult> asyncHandler) {

        return listSAMLProvidersAsync(new ListSAMLProvidersRequest(), asyncHandler);
    }
1123813
@Override
    protected final T create(Object... args) {
        if (this.creating.get()) {
            throw new IllegalStateException(
                    "Singleton creator has been called again while creation is in progress, this is indicative of a creation loop in a single thread");
        }

        this.creating.set(true);
        try {
            final T instance = this.createSingleton(args);
            this.instance = instance;
            this.created.set(true);
            return instance;
        } finally {
            this.creating.set(false);
        }
    }
846905
public static <K, V> ConcurrentMap<K, V> createWeakValueConcurrentMap(int initialCapacity, int concurrencyLevel) {
		return new MapMaker().weakValues().initialCapacity(initialCapacity).concurrencyLevel(concurrencyLevel)
				.makeMap();
	}
1014650
private SslHandshakeResult initializeSocket(SocketChannel sc, boolean clientMode, List<Long> clockSkews)
            throws IOException {
        ByteBuffer timeBuffer = ByteBuffer.allocate(Long.BYTES);
        if (clientMode) {
            synchronized (sc.blockingLock()) {
                boolean isBlocking = sc.isBlocking();
                // Just being lazy and using blocking mode here to get the server's current timestamp
                sc.configureBlocking(true);
                do {
                    sc.read(timeBuffer);
                } while (timeBuffer.hasRemaining());
                sc.configureBlocking(isBlocking);
            }
            if (clockSkews != null) {
                clockSkews.add(System.currentTimeMillis() - ((ByteBuffer) timeBuffer.flip()).getLong());
            }
        } else {
            timeBuffer.putLong(System.currentTimeMillis());
            timeBuffer.flip();
            do {
                sc.write(timeBuffer);
            } while (timeBuffer.hasRemaining());
        }
        return setupSSLIfNeeded(sc, clientMode);
    }
800077
@Override
    public java.util.concurrent.Future<ListHostedZonesResult> listHostedZonesAsync(
            com.amazonaws.handlers.AsyncHandler<ListHostedZonesRequest, ListHostedZonesResult> asyncHandler) {

        return listHostedZonesAsync(new ListHostedZonesRequest(), asyncHandler);
    }
832603
@Override
    public void onKnownIssueNotSynchronized(final AcraReport pReport, final Issue pIssue)
            throws SynchronizationException {

        IssueDescriptionReader reader = null;
        try {
            reader = new IssueDescriptionReader(pIssue);

        } catch (final IssueParseException e) {
            throw new SynchronizationException("Unable to parse description of issue "
                    + pIssue.getId(), e);
        }

        final IssueDescriptionBuilder builder = new IssueDescriptionBuilder(reader.getStacktrace());
        builder.setOccurrences(reader.getOccurrences());
        builder.addOccurrence(IssueDescriptionUtils.toErrorOccurrence(pReport));

        pIssue.setDescription(builder.build());

        try {
            redmineClient.updateIssue(pIssue);
        } catch (final Exception e) {
            pReport.setStatus(SyncStatus.FAILURE);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Failure while updating issue: \n{}",
                        ToStringBuilder.reflectionToString(pIssue, ToStringStyle.MULTI_LINE_STYLE));
            }
            throw new SynchronizationException(
                    String.format("Unable to update issue %s for ACRA report %s", pIssue.getId(),
                            pReport.getId()), e);
        }
        pReport.setStatus(SyncStatus.SUCCESS);
    }
236343
public synchronized boolean sync() {
		if (!validState) {
			throw new InvalidStateException();
		}
		try {
			flushBuffer();
			if (!syncOnFlush) {
				fcOutput.force(false);
				if (callback != null) {
					callback.synched(offsetOutputCommited);
				}
			}
			return true;
		} catch (Exception e) {
			log.error("Exception in sync()", e);
		}
		return false;
	}
128503
static <T> boolean syncInstantiation(T objectType) {
        List<Template> templates = new ArrayList<>();
        Templates tr = TEMP_FINDER.findAnnotations(templates, objectType);
        if (tr == null) {
            /* Default to synchronous instantiation */
            return true;
        } else {
            return tr.syncInstantiation();
        }
    }
932882
static ThreadLocal<Map<String, String>> createThreadLocalMap(final boolean isMapEnabled) {
        final PropertiesUtil managerProps = PropertiesUtil.getProperties();
        final boolean inheritable = managerProps.getBooleanProperty(INHERITABLE_MAP);
        if (inheritable) {
            return new InheritableThreadLocal<Map<String, String>>() {
                @Override
                protected Map<String, String> childValue(final Map<String, String> parentValue) {
                    return parentValue != null && isMapEnabled //
                    ? Collections.unmodifiableMap(new HashMap<>(parentValue)) //
                            : null;
                }
            };
        }
        // if not inheritable, return plain ThreadLocal with null as initial value
        return new ThreadLocal<>();
    }
625916
@Pure
	public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
		return new LinkedHashMap<K, V>();
	}
472450
public static <K,V> Map<K,V> asSynchronized(Map<K,V> self) {
        return Collections.synchronizedMap(self);
    }
1033999
public void setCreate(long now, SimpleOrderedMap<Object> status)
      throws IOException {
    if (action.equals(ComponentCollection.ACTION_CREATE)) {
      this.now = now;
      this.status = status;
    } else {
      throw new IOException("not allowed with action '" + action + "'");
    }
  }