Recently, I have been reviewing this knowledge, and I have done some sorting and summarization to prevent forgetting after reading it. I
will continue to update the content with the progress, which is relatively scattered but try to cover as much as possible.
If there are any mistakes, please correct me~
java thread state diagram:
Thread liveness issues:
- deadlock
- hunger
- livelock
Hunger Causes:
- High priority causes low priority to fail to run (probability)
- Unable to enter synchronized block (such as entering thread stuck in an infinite loop)
- Can't be woken up (no notify)
Conditions for thread safety issues:
- In a multithreaded environment
- Multiple threads share the same resource
- There are non-atomic operations,
just destroy one of them
Synchronized
built-in lock
involves bytecode: monitorenter monitorexit
lock information is stored in the object header
Biased Locks Lightweight Locks Heavyweight Locks Related:
Reference: Locks in
Synchronization
java -- biased locks, lightweight locks, spin locks, heavyweight locks
Update April 26, 2018 02:38