Last active
April 8, 2018 02:27
-
-
Save vbauerster/db7562e1757ecc993f1b5c3768ba6bc9 to your computer and use it in GitHub Desktop.
Diff btw chan size 0 and 1
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 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