TreeMap in Java

TreeMap implements SortedMap. SortedMap is an interface extends the Map interface and provides a total ordering of its elements. 
```
import java.util.*;

public class Main {
    public static void main(String[] args) {
        TreeMap<Integer, String> tm = new TreeMap<>();
        tm.put(10, "Geeks");
        tm.put(15, "4");
        tm.put(20, "Geeks");
        tm.put(25, "Welcomes");
        tm.put(30, "You");
        System.out.println(tm);
    }
}
```
The implementation of a TreeMap is not synchronized. This means that if multiple threads access a tree set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. This is typically accomplished by using the Collections.synchronizedSortedMap method. This is best done at the creation time, to prevent accidental unsynchronized access to the set. This can be done as:
```
SortedMap m = Collections.synchronizedSortedMap(new TreeMap(...)); 
```