concurrency esay

https://medium.com/@trevor4e/learning-gos-concurrency-through-illustrations-8c4aff603b3

Single-threaded

func main() {
 theMine := [5]string{“rock”, “ore”, “ore”, “rock”, “ore”}
 foundOre := finder(theMine)
 minedOre := miner(foundOre)
 smelter(minedOre)
}

Concurrecny

goroutines = create independently working gophers(light-weight threads)

channels = a way for gophers to communicate to each other.

unbuffered, and buffered channels

unbuffered channels = one data fits through the channel at a time.

buffered channels = multiple data fits through the channel at a time.

Last updated

Was this helpful?