1. Basic knowledge of Java
A summary of Java knowledge points, from the basics to commonly used APIs and commonly used collection classes, the summary is very detailed. The pictures were found from the forum and organized for easy review. This is the most detailed and complete mind map I have seen so far, and it is very suitable for those who are just getting started.
2. Object-oriented
3. Commonly used APIs
4. Collection IO
1. What does "collections are thread-unsafe" mean?
First, let’s understand what collections are thread-unsafe:
When multiple concurrent additions, deletions, and modifications are made to non-thread-safe collections at the same time, the data integrity of these collections will be destroyed; for
example: when multiple threads access the same collection or Map, if more than one thread modifies the ArrayList collection, then The program must manually ensure the synchronization of this collection.
2. Thread-safe and thread-unsafe collections
Vector, HashTable, Properties, and ConcurrentHashMap are thread-safe;
ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap, etc. are all thread-unsafe.
It is worth noting that in order to ensure that the collection is thread-safe, the corresponding efficiency is relatively low; the efficiency of a thread-unsafe collection will be relatively higher.
3. How to comprehensively consider the issues of thread insecurity and low efficiency
In order to ensure that collections are both safe and efficient, Collections provides us with a solution to wrap these collections into thread-safe collections.
Collections provides the following static methods.
//返回指定collection 对应的线程安全的collection。
<T> Collection<T> synchronizedCollection(Collection<T> c);
//返回指定List对象对应的线程安全的List 对象。
static <T> List<T> synchronizedList(List<T> list);
//返回指定Map对象对应的线程安全的Map对象。
static <K, V> Map<K, V> synchronizedMap(Map<K, V> m);
//返回指定Set对象对应的线程安全的Set对象。
static <T> Set<T> synchronizedSet(Set<T> s);
//返回指定SortedMap对象对应的线程安全的SortedMap对象。
static <K, V> SortedMap<K, V> synchronizedSortedMap(SortedMap<K, V> m);