示例#1
0
文件: chain.go 项目: 8l/go-learn
func link(left chan<- int, right <-chan int) {
	// Keep the links in dedicated operating system
	// threads, so that this program tests coordination
	// between pthreads and not just goroutines.
	runtime.LockOSThread()
	for {
		v := <-right
		stdio.Puts(strconv.Itoa(v))
		left <- 1 + v
	}
}
示例#2
0
文件: chain.go 项目: 8l/go-learn
func main() {
	leftmost := make(chan int)
	var left chan int
	right := leftmost
	for i := 0; i < N; i++ {
		left, right = right, make(chan int)
		go link(left, right)
	}
	for i := 0; i < R; i++ {
		right <- 0
		x := <-leftmost
		stdio.Puts(strconv.Itoa(x))
	}
}
示例#3
0
文件: fib.go 项目: ivanwyc/google-go
func fibber(c, out chan int64, i int64) {
	// Keep the fibbers in dedicated operating system
	// threads, so that this program tests coordination
	// between pthreads and not just goroutines.
	runtime.LockOSThread()

	if i == 0 {
		c <- i
	}
	for {
		j := <-c
		stdio.Puts(strconv.Itoa64(j))
		out <- j
		<-out
		i += j
		c <- i
	}
}
示例#4
0
func main() {
	//	stdio.Stdout.WriteString("hello, world\n");
	stdio.Puts("hello, world")
}