Skip to content

Instantly share code, notes, and snippets.

@daved
Created April 10, 2018 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daved/e6c342b1deec80a3b8a914e83095b989 to your computer and use it in GitHub Desktop.
Save daved/e6c342b1deec80a3b8a914e83095b989 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan int)
go func() {
time.Sleep(time.Millisecond * 5)
fmt.Println("calculated result")
c <- 42
}()
fmt.Println("waiting")
fmt.Printf("the answer is %d\n", <-c)
}
// from https://github.com/crabmusket/haskell-simple-concurrency/blob/aeb440a16f69eab46a8786019af5f69f436d7186/src/MVars.hs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment