【发布时间】:2014-05-29 05:54:06
【问题描述】:
我有一张地图,供 goroutine A 使用,并在 goroutine B 中一次替换一次。我的意思是:
var a map[T]N
// uses the map
func goroutineA() {
for (...) {
tempA = a
..uses tempA in some way...
}
}
//refreshes the map
func gorountineB() {
for (...) {
time.Sleep(10 * time.Seconds)
otherTempA = make(map[T]N)
...initializes other tempA....
a = otherTempA
}
}
你觉得这个伪代码有什么问题吗? (就并发而言)
【问题讨论】:
标签: go