Java Code Examples for java.util.Collections.synchronizedSortedMap()

The following are Jave code examples for showing how to use synchronizedSortedMap() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: SaasGroup.java   View Source Code Vote up 5 votes
public List<SaasGroup> getChildrenGroups() {
    if (children == null) {
        children = Collections.synchronizedSortedMap(new TreeMap<String,SaasGroup>());
        for (Group g : delegate.getGroup()) {
            SaasGroup sg = new SaasGroup(this, g);
            children.put(sg.getName(), sg);
        }
    }
    return new ArrayList<SaasGroup>(children.values());
}
 
Example 2
Project: incubator-netbeans   File: SaasGroup.java   View Source Code Vote up 4 votes
public SaasGroup(SaasGroup parent, Group group) {
    this.parent = parent;
    this.delegate = group;
    services = Collections.synchronizedSortedMap(new TreeMap<String, Saas>());
}
 
Example 3
Project: openjdk-systemtest   File: MessageHeader.java   View Source Code Vote up 4 votes
MessageHeader() {
	map = Collections.synchronizedSortedMap(new TreeMap<String, String>());
}
 
Example 4
Project: jdk8u-jdk   File: java_util_Collections_SynchronizedSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    map.put("key", "value");
    return Collections.synchronizedSortedMap(map);
}
 
Example 5
Project: jdk8u-jdk   File: java_util_Collections_SynchronizedSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getAnotherObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    return Collections.synchronizedSortedMap(map);
}
 
Example 6
Project: openjdk-jdk10   File: java_util_Collections_SynchronizedSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    map.put("key", "value");
    return Collections.synchronizedSortedMap(map);
}
 
Example 7
Project: openjdk-jdk10   File: java_util_Collections_SynchronizedSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getAnotherObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    return Collections.synchronizedSortedMap(map);
}
 
Example 8
Project: HCFCore   File: MapUtils.java   View Source Code Vote up 2 votes
/**
 * Returns a synchronized sorted map backed by the given sorted map.
 * <p>
 * You must manually synchronize on the returned buffer's iterator to
 * avoid non-deterministic behavior:
 *
 * <pre>
 * Map m = MapUtils.synchronizedSortedMap(myMap);
 * Set s = m.keySet();  // outside synchronized block
 * synchronized (m) {  // synchronized on MAP!
 *     Iterator i = s.iterator();
 *     while (i.hasNext()) {
 *         process (i.next());
 *     }
 * }
 * </pre>
 *
 * This method uses the implementation in {@link java.util.Collections Collections}.
 *
 * @param <K>  the key type
 * @param <V>  the value type
 * @param map  the map to synchronize, must not be null
 * @return a synchronized map backed by the given map
 * @throws NullPointerException  if the map is null
 */
public static <K, V> SortedMap<K, V> synchronizedSortedMap(final SortedMap<K, V> map) {
    return Collections.synchronizedSortedMap(map);
}
 
Example 9
Project: HCFCore   File: MapUtils.java   View Source Code Vote up 2 votes
/**
 * Returns a synchronized sorted map backed by the given sorted map.
 * <p>
 * You must manually synchronize on the returned buffer's iterator to
 * avoid non-deterministic behavior:
 *
 * <pre>
 * Map m = MapUtils.synchronizedSortedMap(myMap);
 * Set s = m.keySet();  // outside synchronized block
 * synchronized (m) {  // synchronized on MAP!
 *     Iterator i = s.iterator();
 *     while (i.hasNext()) {
 *         process (i.next());
 *     }
 * }
 * </pre>
 *
 * This method uses the implementation in {@link java.util.Collections Collections}.
 *
 * @param <K>  the key type
 * @param <V>  the value type
 * @param map  the map to synchronize, must not be null
 * @return a synchronized map backed by the given map
 * @throws NullPointerException  if the map is null
 */
public static <K, V> SortedMap<K, V> synchronizedSortedMap(final SortedMap<K, V> map) {
    return Collections.synchronizedSortedMap(map);
}