doc: add explanation of sync.Mutex
This commit is contained in:
		
							parent
							
								
									1703797170
								
							
						
					
					
						commit
						f16bfef103
					
				
							
								
								
									
										13
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								README.md
									
									
									
									
									
								
							@ -36,3 +36,16 @@ select {
 | 
				
			|||||||
        // receive when c is blocked        
 | 
					        // receive when c is blocked        
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## sync.Mutex  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Channels are great for communication, but what if we don't need communication?  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					What if we just want to make sure only one goroutine can access a variable at a time to avoid conflicts? This concept is called `mutual exclusion`, and the conventional name for the data structure that provides it is `mutex`  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Go's standard library provides mutual exclusion with `sync.Mutex` and its two methods: `Lock` and `Unlock`  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## sync.WaitGroup  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https://tutorialedge.net/golang/go-waitgroup-tutorial/
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user