java.util.Collections.synchronizedSortedMap() 方法


java.util.Collections.synchronizedSortedMap() 方法

package com.codingdict;

import java.util.*;

public class CollectionsDemo {
   public static void main(String[] args) {

      // create map
      SortedMap<String,String> map = new TreeMap<String, String> ();

      // populate the map
      map.put("1","TP");
      map.put("2","IS");
      map.put("3","BEST");

      // create a sorted map
      SortedMap sortedmap = (SortedMap)Collections.synchronizedSortedMap(map);

      System.out.println("Synchronized sorted map is :"+sortedmap);
   }
}