Go
Goroutines and Channels

Concurrency in Go

Concurrency is the ability to perform multiple tasks at the same time. line by line == sequential/synchronous

If the computer we're running our code on has multiple cores, we can even execute multiple tasks at exactly the same time. If we're running on a single core, a single core executes code at almost the same time by switching between tasks very quickly. Either way, the code we write looks the same in Go and takes advantage of whatever resources are available.

Go was designed to be concurrent, which is a trait fairly unique to Go. It excels at performing many tasks simultaneously safely using a simple syntax.

Goroutines

Concurrency is as simple as using go when calling a function

go doSmth()

This spawns a new goroutine (lightweight thread of execution)

Channels

Channels are a typed, thread-safe queue. Channels allow different goroutines to communicate with each other.