blob: e8b3d243949f2c09b0976edf1da5b4c433bfa5b1 [file] [log] [blame]
Rémy Oudompheng2ece2f52012-02-18 22:15:42 +01001// run
Ian Lance Taylorbe827822009-05-02 12:47:33 -07002
3// Copyright 2009 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package main
Rob Pike325cf8e2010-03-24 16:46:53 -07008
Ian Lance Taylorbe827822009-05-02 12:47:33 -07009import "time"
Rob Pike325cf8e2010-03-24 16:46:53 -070010
Ian Lance Taylorbe827822009-05-02 12:47:33 -070011func main() {
Rob Pike325cf8e2010-03-24 16:46:53 -070012 var count int
13 c := make(chan byte)
Ian Lance Taylorbe827822009-05-02 12:47:33 -070014 go func(c chan byte) {
Rob Pike325cf8e2010-03-24 16:46:53 -070015 <-c
16 count++
17 time.Sleep(1000000)
18 count++
19 <-c
20 }(c)
21 c <- 1
22 c <- 2
23 if count != 2 {
24 panic("synchronous send did not wait")
25 }
Ian Lance Taylorbe827822009-05-02 12:47:33 -070026}