Learn more about Java basics


My personal ability is limited. In the learning process, I found that these two series of articles are very comprehensive and can learn from each other. It is suggested to learn and read the two series of articles for many times

  • 27 articles summarize the basics of Java concurrency in detail
  • Dead knock Java concurrency

supplement

Bias lock/lightweight lock/heavyweight lock

Talk about partial lock, lightweight lock, heavyweight lock

About unfair locks and AQS

AQS parsing

Concurrent programming – detailed explanation of AQS CLH lock

There is a synchronization queue in AQS, which is a double-linked list queue, which is a FIFO queue. So when a thread fails to acquire the lock and enters the synchronization queue blocking wait, it is no longer a simultaneous contention and will be released in the synchronization queue order. Simultaneous contention with an unfair lock means that, without a lock, multiple threads start to compete at the same time, regardless of whether there are blocked threads in the synchronized queue. For example, Thread1 releases the lock, and the synchronization queue has T2, T3. If the non-fair lock thread T4 starts to compete at this time, it is highly likely to be acquired by T4. If there are no other unfair locks to compete with, the T2 threads are released sequentially to acquire the lock.

In-depth analysis of ConcurrentHashMap1.8

In-depth analysis of ConcurrentHashMap1.8 expansion implementation

Data replication from table[] to NewTable [] during capacity expansion