Java concurrent threads read the follow-up (two)

Continued article

Ways to avoid deadlock

  1. Avoid a thread simultaneously acquire multiple locks;
  2. Avoid a thread simultaneously occupy multiple resources in the lock, try to ensure that each lock only takes one resource;
  3. Try using time lock, using lock.tryLock (timeout) instead of using the internal locking mechanism;
  4. For database locks, locking and unlocking must be a database connection, otherwise the situation will unlock failure occurs;

Definition of the CPU

the term English words Term Description
Memory barrier memory barriers It is a set of processor instructions, for implementing a sequential operation limit memory
Cache line Cache line The minimum unit of storage that can be allocated in the cache, it will load the entire cache line fill cache line while the processor, a plurality of memory read cycles required
Atomic operation atomic operations Or a series of operations can not be interrupted
A cache line fill cache line fill When the processor recognizes the number of read operations from the memory is cacheable, the processor reads the entire cache line to the appropriate cache (L1, L2, L3, or all)
Cache Hit cache hit If the cache line fill operation of the memory location is still accessible to the processor when the next address. The processor reads the operands from the cache instead of reading from memory
Write hit write hit When the processor operand is written back to a memory cache area, it first checks the cache memory address is in the cache line, if there is a valid cache line, the processor will return to write the operand cache instead of writing back to memory, this operation is called write hit
Write miss write misses the cache A valid cache line is written to the memory area does not exist

Object header structure

Here Insert Picture Description

Published 21 original articles · won praise 4 · Views 510

Guess you like

Origin blog.csdn.net/weixin_39617728/article/details/104875277