1 Threads, Processes, And Goroutines
Thread
- share memory (virtual address space VAS) & resource
- scheduled independently
- if multiple CPUs, run simultaneously
Process
- contains multiple threads
- independent VAS
Goroutines
- Go version of threads
- More lightweight than OS threads
- OS context switches are expensive
- Go scheduler switches between goroutines, cheap
- Go runtime
- assigns goroutines to OS threads
- manages context switches of threads
- maintains a queue of goroutines