Your question makes no sense because Map
is an interface type, and thread safety is an implementation property.
That being said, the most commonly used Map
implementations, specifically HashMap
are not thread safe. Adding elements from different threads can leave the map in an inconsistent state where e.g. elements that have been inserted cannot be retrieved though size()
shows that they're present.
You can use Collections.synchronizedMap()
to create a synchronized wrapper, or use the old Hashtable
class (not recommended) which is also synchronized. But note that these are still only threadsafe for single operations - sequences of operations that depend on each other, like iteration through the map, still need additional manual synchronization.
ConcurrentHashMap
is a very interesting implementation that allows certain kinds of multithreaded access without using sychronization, resulting in very good performance when there are lots of threads accessing it in parallel. But it's not applicable for all use cases.