Skip to content

VivekRamchandani/go-concurrency-working

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concurrent Programming in Go

This repository holds codes of concurrent programming tools like mutexs, semaphores, wait groups, etc.

Mutexes

Mutexes is short for mutual exclusion. Mutexes make access to shared memory synchronous while modifying them. Thus blocking concurrency when modifying the shared resources and preventing race conditions.

Mutexes

Conditional Variable

Condition variables work together with mutexes and give us the ability to block the current execution until we have a signal that a particular condition has changed.

Conditional Variable

Read-Write Mutex

Because of greedy executions, the shared resource may be made unavailable for a long time, which prevents write execution from gaining access to a shared resource. This issue can be solved by using a Read-Write Mutex with write-preferred lock.

RWMutex

Semaphore

Semaphore let us control the number of concurrent execution that are permitted to execute at the same time.

Semaphore

Wait Group

Wait Groups can make a goroutine wait for a set of concurrent task to complete.

Wait Groups

Barrier

Barrier is a type of syncronization method that is used to make a group of goroutines execute some code at the same time.

Barrier

Channels

Channels lets two or more goroutines exchange messages. Goroutines can use the ends of channel to send or recieve messages.

Channels