Go Routines
- Go routines is a way to spawn code so that it can be run in parallel or concurrently
The Main Routine
- The
main routine is the top-level routine on your program. Other routines can be spawn from it
- Other routines are called
child routines and are created using the go keyword
Go scheduler
- The routines are managed by the
Go scheduler which uses by default all the available cores at your machine
- The go scheduler manages the go routines by applying
context switching (interrupting some routines and resuming others)
- The context switching is usually executed when the routine is in a wait state (e.g., http calls)
- With these concurrency techniques the overall utilization of a single thread is improved
Channels
- It's a hub for communication between go routines
- Channels are typed. The messages sent through a channel must be of the same type