CMSC 335 Homework 4 Complete Solution
1. (20 pts) For the following program, explain the interesting lines of code related to threads and explain the output of the application (do not show the output, just explain it).
You may experiment with the program using the attached source code by copying and pasting it into your IDE.
11
15
20
CMSC 335 Homework 4 Complete Solution
DEADLOCK What if every philosopher sits down about the same time and picks up his left chopstick. In this case, all chopsticks are locked and none of the philosophers can successfully lock his right chopstick. As a result, we have a circular waiting (i.e., every philosopher waits for his right chopstick that is currently being locked by his right neighbor), and hence a deadlock occurs. STARV...
A+ - Thank you!
Thanks for the positive feedback!