In this video, learn how to recognize that the conditions for a data race do not exist if multiple threads are all reading the same shared resource, only if at least one of the threads is writing to it. Gain an understanding of how the combination of read and write locks can allow multiple simultaneous reader threads by limiting access to only one thread when writing will occur.
- We use a locker mutex to protect a critical section … of code to defend against data races, … which can occur when multiple threads … are concurrently accessing the same location in memory … and at least one of those threads … is writing to that location. … That second part is key, … because if we have a bunch of threads … and none of them are writing, … they are all just want to read … from the same location, that's fine. … It's okay to let multiple threads read the same shared value … as long as no one else can change it. … They'll all safely see the same thing. … Danger only exists when you add … a thread that's writing to the mix. … When we use a basic lock … or a mutex to protect the shared resource, … we limit access so that only … one of the threads can use it at a time, … regardless of whether that thread … is reading, or writing, or both. … - That works but it's not necessarily the most efficient way … to do things, especially when there are lots of threads … that only need to read. …
- 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.