java.util.Collections.synchronizedSortedSet()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中java.util.Collections.synchronizedSortedSet()方法的一些代码示例,展示了Collections.synchronizedSortedSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collections.synchronizedSortedSet()方法的具体详情如下:
包路径:java.util.Collections
类名称:Collections
方法名:synchronizedSortedSet

Collections.synchronizedSortedSet介绍

[英]Returns a wrapper on the specified sorted set which synchronizes all access to the sorted set.
[中]返回指定排序集上的包装器,该包装器同步对排序集的所有访问。

代码示例

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * A convenience method for creating a synchronized SortedSet.
 *
 * @param self a SortedSet
 * @return a synchronized SortedSet
 * @see java.util.Collections#synchronizedSortedSet(java.util.SortedSet)
 * @since 1.0
 */
public static <T> SortedSet<T> asSynchronized(SortedSet<T> self) {
  return Collections.synchronizedSortedSet(self);
}

代码示例来源:origin: org.apache.commons/commons-collections4

/**
 * Returns a synchronized sorted set backed by the given sorted set.
 * <p>
 * You must manually synchronize on the returned set's iterator to
 * avoid non-deterministic behavior:
 *
 * <pre>
 * Set s = SetUtils.synchronizedSortedSet(mySet);
 * synchronized (s) {
 *     Iterator i = s.iterator();
 *     while (i.hasNext()) {
 *         process (i.next());
 *     }
 * }
 * </pre>
 *
 * This method is just a wrapper for {@link Collections#synchronizedSortedSet(SortedSet)}.
 *
 * @param <E> the element type
 * @param set  the sorted set to synchronize, must not be null
 * @return a synchronized set backed by the given set
 * @throws NullPointerException if the set is null
 */
public static <E> SortedSet<E> synchronizedSortedSet(final SortedSet<E> set) {
  return Collections.synchronizedSortedSet(set);
}

代码示例来源:origin: wildfly/wildfly

classes.add(Collections.synchronizedSet(Collections.emptySet()).getClass());
classes.add(Collections.synchronizedSortedMap(Collections.emptySortedMap()).getClass());
classes.add(Collections.synchronizedSortedSet(Collections.emptySortedSet()).getClass());

代码示例来源:origin: protostuff/protostuff

synchronizedSortedSet = Collections.synchronizedSortedSet(ts);
synchronizedList = Collections.synchronizedList(ll);
synchronizedRandomAccessList = Collections

代码示例来源:origin: spring-projects/spring-batch

final SortedSet<Long> ids = Collections.synchronizedSortedSet(new TreeSet<>()); // TODO Change to SkipList w/JDK6
final AtomicReference<Exception> exception = new AtomicReference<>(null);

代码示例来源:origin: apache/geode

boolean sameSizeVarSetFlag = false;
SortedSet testSet =
  Collections.synchronizedSortedSet(new TreeSet(new SelectResultsComparator()));
for (int i = 0; i < 10; i++) {
 Random rand = new Random();

代码示例来源:origin: resteasy/Resteasy

sortedParamConverterProviders = Collections.synchronizedSortedSet(parent == null ? new TreeSet<>() : new TreeSet<>(parent.getSortedParamConverterProviders()));
stringParameterUnmarshallers = parent == null ? new ConcurrentHashMap<>() : new ConcurrentHashMap<>(parent.getStringParameterUnmarshallers());
reactiveClasses = parent == null ? new ConcurrentHashMap<>() : new ConcurrentHashMap<>(parent.reactiveClasses);

代码示例来源:origin: magro/kryo-serializers

@Override
  public Object create( final Object sourceCollection ) {
    return Collections.synchronizedSortedSet( (SortedSet<?>) sourceCollection );
  }
},

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * A convenience method for creating a synchronized SortedSet.
 *
 * @param self a SortedSet
 * @return a synchronized SortedSet
 * @see java.util.Collections#synchronizedSortedSet(java.util.SortedSet)
 * @since 1.0
 */
public static <T> SortedSet<T> asSynchronized(SortedSet<T> self) {
  return Collections.synchronizedSortedSet(self);
}

代码示例来源:origin: de.javakaffee/kryo-serializers

@Override
  public Object create( final Object sourceCollection ) {
    return Collections.synchronizedSortedSet( (SortedSet<?>) sourceCollection );
  }
},

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

/**
 * A convenience method for creating a synchronized SortedSet.
 *
 * @param self a SortedSet
 * @return a synchronized SortedSet
 * @see java.util.Collections#synchronizedSortedSet(java.util.SortedSet)
 */
public static SortedSet asSynchronized(SortedSet self) {
  return Collections.synchronizedSortedSet(self);
}

代码示例来源:origin: resteasy/Resteasy

.synchronizedSortedSet(new TreeSet<>(parent.getSortedParamConverterProviders()));

代码示例来源:origin: locationtech/geowave

protected SortedSet<MemoryStoreEntry> getRowsForIndex(final String id) {
 SortedSet<MemoryStoreEntry> set = storeData.get(id);
 if (set == null) {
  set = Collections.synchronizedSortedSet(new TreeSet<MemoryStoreEntry>());
  storeData.put(id, set);
 }
 return set;
}

代码示例来源:origin: resteasy/Resteasy

.synchronizedSortedSet(new TreeSet<>(parent.getSortedParamConverterProviders()));

代码示例来源:origin: org.maltparser/maltparser

protected SortedSet<DependencyNode> getSortedSetOfLeftDependents(int nodeIndex) {
  SortedSet<DependencyNode> leftDependents = Collections.synchronizedSortedSet(new TreeSet<DependencyNode>());
  for (int i = 1; i < nodeIndex; i++) {
    if (nodeIndex == nodes.get(i).getHeadIndex()) {
      leftDependents.add(nodes.get(i));
    }
  }
  return leftDependents;
}

代码示例来源:origin: org.maltparser/maltparser

public SortedSet<DependencyNode> getHeads() {
  SortedSet<DependencyNode> heads = Collections.synchronizedSortedSet(new TreeSet<DependencyNode>());
  DependencyNode head = getHead();
  if (head != null) {
    heads.add(head);
  }
  return heads; 
}

代码示例来源:origin: org.onap.ccsdk.sli.core/dblib-provider

public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) {
  this.parent = parent;
  completionCounter = new AtomicLong(0L);
  interval = parent.getInterval();
  initialDelay = parent.getInitialDelay();
  this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold();
  this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime() * MILISECOND;
  innerSet = Collections.synchronizedSortedSet(new TreeSet<TestObject>());
  timer = new Timer();
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

private void reset() {
    // set all values back to their default values (used for running
    // the algorithm more than once)
//        nodes = new TreeSet<OENode>(heuristic);
    searchTree = new SynchronizedSearchTree(heuristic);
    //Sets.synchronizedNavigableSet(new TreeSet<OENode>(Collections.reverseOrder(heuristic)));
    descriptions = Collections.synchronizedSortedSet(new TreeSet<>());
    bestEvaluatedDescriptions.getSet().clear();
    expressionTests = 0;
    highestAccuracy = 0.0;
  }

代码示例来源:origin: org.terracotta.modules/tim-tree-map-cache

protected TerracottaTreeCache(int mapImpl) {
  this.mapImpl = mapImpl;
  if (isThreadSafe) {
    cacheTree = Collections.synchronizedSortedMap(new TreeMap<Fqn,Map>(new Fqn()));
    fqnSet = Collections.synchronizedSortedSet(new TreeSet<Fqn>(new Fqn()));
  } else {
    cacheTree = new TreeMap<Fqn,Map>(new Fqn());
    fqnSet = new TreeSet<Fqn>(new Fqn());
  } 
}

代码示例来源:origin: org.terracotta.modules/tim-tree-map-cache

protected TerracottaTreeCache(boolean isThreadSafe) {        
  if (isThreadSafe) {
    cacheTree = Collections.synchronizedSortedMap(new TreeMap<Fqn,Map>(new Fqn()));
    fqnSet = Collections.synchronizedSortedSet(new TreeSet<Fqn>(new Fqn()));
  } else {
    cacheTree = new TreeMap<Fqn,Map>(new Fqn());
    fqnSet = new TreeSet<Fqn>(new Fqn());
  }
}

相关文章

微信公众号

最新文章

更多

Collections类方法