CSE224 - Go Concurrent Programming
Introduction
Go Routines
Traditionally, people used OS-level threads for concurrency, but threads are heavyweight. Go introduced goroutines, which are
- Very cheap in terms of memory
- Managed by the Go runtime, not the OS
- Can be created in large numbers
Go uses an internal scheduler that maps many goroutines onto fewer OS threads using something called the M:N model (many goroutines on few threads). The scheduler runs in user space — no need to ask the operating system every time. As a result, go routines is like a user-level thread.
1 |
|
Channel
A channel is a way for goroutines to communicate and synchronize with each other. It’s like a pipe.
1 |
|
Channels can be synchronous or buffered:
- Synchronous: No buffer. The sender waits until a receiver is ready.
1 |
|
- Buffered: Has space to hold values. Sender doesn’t wait until buffer is full.
1 |
|
CSE224 - Go Concurrent Programming
https://thiefcat.github.io/2025/05/10/CSE224/go-concurrent/