In this video, explore the dining philosophers scenario with an example Java program. Learn how to implement a simple solution to resolve the deadlock by prioritizing the order in which each of the available locks will be acquired.
- [Instructor] To demonstrate a Deadlock … with the Dining Philosopher's problem … and how to solve it, I'm going to expand our scenario … from having just two philosophers, Olivia and me, … to having three philosophers, … Olivia, me, and our buddy Steve, … and we're each competing for two of the three chopsticks … placed around the table, labeled here as A, B, and C. … In this example Java program, … I've defined a Philosopher class on line seven … to represent a philosopher who thinks and eats sushi. … The philosopher has two instance variables on line nine … named firstChopstick and secondChopstick, … which are the two locks it will acquire in that order … as well as a static class variable on line 10 … to represent the amount of sushi … left between all of the philosophers. … When I instantiate a philosopher, … I'll pass a pair of locks to the constructor method … defined on line 12, which will assign them … to the first and second chopstick positions. … Down in the philosopher's run method, …
- Parallel vs. sequential computing
- Shared vs. distributed memory
- Execution scheduling
- Thread lifecycle
- Mutual exclusion
- Synchronized methods
- Checking for liveness
Skill Level Advanced
Java Essential Training: Objects and APIswith David Gassner2h 46m Intermediate
Java Essential Training: Syntax and Structurewith David Gassner3h 9m Intermediate
1. Parallel Computing Hardware
2. Threads and Processes
3. Mutual Exclusion
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.