Mutex Lock Udacity https://www.youtube.com/watch?v=9lAuS6jsDgE Transkript (automatisch erstellt) 0:00 Now, in real life if I want to keep other people from taking my things or messing with things they shouldn't, I use 0:05 a lock to stop them. In threaded programming, we use a similar concept to protect memory. Let's say that inside some procedure, there's 0:11 a block where I manipulate some data, in our example, the variable a. And I need to be sure that no other thread 0:17 touches this variable while I am working on it. Whether executing this procedure or another one. Well then, I can declare a lock 0:25 variable, which should reside in shared memory, and put the lock on before I have it do my manipulation, 0:31 and unlock it afterwards. And I should do the same wherever I manipulate this variable a. If some other 0:37 thread running this code simply accesses the shared resource without using the lock, it won't be able to stop 0:43 him. But if he does try to acquire the lock first, then this call to mutex lock will block until 0:51 the lock variable shows that has been unlocked. And only then will this code proceed. And, of course, if 0:57 the schedule had worked things out so that this call had been called first, then he would get the lock. 1:03 And this call to acquire the mutex lock would block until this data manipulation was finished, and the mutex variable 1:10 had been unlocked. And this way the threads are able to mutually exclude each other from using resources, hence these 1:16 are called mutex locks.