Skip to content

Instantly share code, notes, and snippets.

@vbauerster
Last active April 8, 2018 02:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vbauerster/db7562e1757ecc993f1b5c3768ba6bc9 to your computer and use it in GitHub Desktop.
Save vbauerster/db7562e1757ecc993f1b5c3768ba6bc9 to your computer and use it in GitHub Desktop.
Diff btw chan size 0 and 1
package main
import (
"fmt"
"time"
)
func main() {
// c := make(chan struct{}, 1)
c := make(chan struct{})
go func() {
time.Sleep(2 * time.Second)
<-c
}()
start := time.Now()
c <- struct{}{}
elapsed := time.Since(start)
fmt.Printf("Elapsed: %v\n", elapsed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment