Complicated by
Active issues:
1, Deadlock: Thread A, B has a variety of locking resources while fighting for each other's resources.
2. Hunger: Some threads are not running. (Thread priorities)
3, livelocks: Thread A, B to give way, not to do it.
Hunger produced:
1, thread priority. (Taking into account differences in the system)
2, thread A, B performs the same sync block; A blocked thread, thread B waiting A lock release.
3, the thread never wakes up.
Avoid hunger:
1, to set reasonable priority.
2, Lock synchronization.
Emergence of multi-threading issues:
1, multi-threaded environment
2, multiple threads compete for the same resources.
3, competition for resources for non-atomic operation.
Built-in synchronized lock:
JVM byte code level:
the monitorenter // byte code lock
synchronized () {}
the monitorexit bytecodes // release lock