Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example2 adding cut command Mar 15, 2019
example3 Clarify some rune counting loops (#228) Oct 30, 2017
exercises Moved Go class under its own topic. (#182) Feb 25, 2017 Update (#269) Sep 26, 2019
scheduler.png scheduler changes Oct 21, 2018


Goroutines are functions that are created and scheduled to be run independently by the Go scheduler. The Go scheduler is responsible for the management and execution of goroutines.


  • Goroutines are functions that are scheduled to run independently.
  • We must always maintain an account of running goroutines and shutdown cleanly.
  • Concurrency is not parallelism.
    • Concurrency is about dealing with lots of things at once.
    • Parallelism is about doing lots of things at once.

"Parallelism is TRYING to do two things at the same time. Concurrency is arranging it so you can do two things at the same time." - Dave Cheney

Design Guidelines


How the scheduler works.

Ardan Labs


Scheduling In Go - Part I - William Kennedy
Scheduling In Go - Part II - William Kennedy
Scheduler Tracing In Go - William Kennedy
Advanced Go Concurrency Patterns - Sameer Ajmani
Go Concurrency Patterns: Context - Sameer Ajmani
Concurrency is not parallelism - Rob Pike
Go, for Distributed Systems - Russ Cox
Go 1.5 GOMAXPROCS Default
Concurrency, Goroutines and GOMAXPROCS - William Kennedy
The Linux Scheduler: a Decade of Wasted Cores
Explanation of the Scheduler
15 Years of Concurrency - Joe Duffy
How does the golang scheduler work? - Ian Lance Taylor
The Scheduler Saga - Kavya Joshi

Code Review

Goroutines and concurrency (Go Playground)
Goroutine time slicing (Go Playground)
Goroutines and parallelism (Go Playground)


Exercise 1

Part A Create a program that declares two anonymous functions. One that counts down from 100 to 0 and one that counts up from 0 to 100. Display each number with an unique identifier for each goroutine. Then create goroutines from these functions and don't let main return until the goroutines complete.

Part B Run the program in parallel.

Template (Go Playground) | Answer (Go Playground)

All material is licensed under the Apache License Version 2.0, January 2004.

You can’t perform that action at this time.