Sometimes we need to make collections Thread-safe for use in
Multi-threading environment. In Java, Collections class provides
useful static methods to make a List, Set or Map as synchronized
collections. Some of these methods are:
static
c)
Returns a synchronized (thread-safe) collection backed by the
specified collection.
static
Returns a synchronized (thread-safe) list backed by the specified
list.
static
Returns a synchronized (thread-safe) map backed by the specified
map.
static
Returns a synchronized (thread-safe) set backed by the specified
set.
static
SortedMap
Returns a synchronized (thread-safe) sorted map backed by the
specified sorted map.
static
Returns a synchronized (thread-safe) sorted set backed by the
specified sorted set
https://javaconceptoftheday.com/synchronize-arraylist-hashset-and-hashmap-in-java/