The document discusses concurrent programming in Go. It provides an introduction to Go and its characteristics like being statically typed and garbage collected. It then discusses concurrency in Go using goroutines which are lightweight threads, channels for communicating between goroutines, and sync primitives like WaitGroup and Mutex for synchronization. Finally, it provides examples of using concurrency for processing a large CSV file by distributing the work across multiple goroutines.
8. Concurrency
• Concurrency is the composition of independently executing
processes. Concurrency is about dealing with lots of things at once
• Parallelism is the simultaneous execution of (possibly related)
computations. Parallelism is about doing lots of things at once
• Concurrency is about structure, parallelism is about execution
• Concurrency provides a way to structure a solution to solve a problem
that may (but not necessarily) be parallelizable
11. • A goroutine is a lightweight thread managed by the Go runtime
• Not free, but very cheap (4KB ~ 8KB per each goroutine)
• Stacks start small, but grow and shrink as required
Goroutine