What I will learn:
- How to use go routines
- How to use waitgroups and mutexes
- How to use channels
- Single Taslk
- Concurrency (multiple task)
- Parallelism (execute multiple task simultaneously)
Thread | Goroutines |
---|---|
Have own execution stack | Have own execution stack |
Fixed stack space(around 1 MB) | Variable stack space (starts @2 KB) |
Managed by OS | Managed by Go runtime |
- Enable concurrent programming
The Sync Package (golang.org/pkg/sync/)
- Allow goroutines to coordinate their work
- Coordinate tasks
- Waitgroups
- Shared Memory
- Mutexes
A WaitGroup waits for a collection of goroutines to finish.
A mutual exclusion lock.
A tool to detect race conditions:
go run --race .
- Sync.Mutex
- Sync.RWMutex
- Provide a safe way for goroutines to communicate