Deadlock in Java

Опубликовано: 31 Октябрь 2024
на канале: Jakob Jenkov
23,257
614

Deadlock is a situation that can occur when two or more threads are blocked indefinitely trying to obtain access to a resource locked by the other threads in the deadlock. Thus, the deadlocked threads are blocked, waiting for each other to release a resource which neither of them can release because they are blocked waiting for the other thread to release its resource first.

Such resources can be Java Locks, Java synchronized blocks (Java monitor objects), files, database tables and / or records etc.

Chapters:

0:00 Deadlock defintion
1:04 Deadlock code example using two Lock instances in Java
5:43 Deadlock code example using two synchronized blocks in Java
7:19 Deadlock can occur with any mutually exclusive access / lockable resource
7:57 Deadlock fix via lock ordering
8:54 More complex deadlock scenario
11:14 A deadlock will block all threads trying to lock a resource involved in the deadlock
12:50 The four conditions required for a deadlock to occur
15:44 Other problems similar to deadlock

Deadlock in Java - text:
http://tutorials.jenkov.com/java-conc...

Deadlock Prevention in Java - video:
   • Deadlock in Java  

Java Concurrency Tutorial - text / video
http://tutorials.jenkov.com/java-conc...
   • Java Concurrency and Multithreading  

Starvation and Fairness - text:
http://tutorials.jenkov.com/java-conc...

Nested Monitor Lockout - text:
http://tutorials.jenkov.com/java-conc...

Reentrance Lockout - text:
http://tutorials.jenkov.com/java-conc...

Java Lock - text / video
http://tutorials.jenkov.com/java-util...
   • Java Lock