10.5.3 通过goroutine共享内存
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"sync"
"time"
)
var readValue = make(chan int)
var writeValue = make(chan int)func set(newValue int) {
writeValue <-newValue
}
func read() int {
return <-readValue
}Last updated