Created
April 10, 2018 21:03
-
-
Save daved/e6c342b1deec80a3b8a914e83095b989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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