Java tutorial
import java.util.Collections; import java.util.SortedMap; import java.util.TreeMap; public class Main { public static void main(String[] args) { // create map SortedMap<String, String> map = new TreeMap<String, String>(); // populate the map map.put("1", "A"); map.put("2", "B"); map.put("3", "from java2s.com"); // create a sorted map SortedMap<String, String> sortedmap = (SortedMap<String, String>) Collections.synchronizedSortedMap(map); System.out.println("Synchronized sorted map is :" + sortedmap); } }