标签:
//go func 和主线程之间的关系是并行和竞争关系
package main import ( "fmt" "sync" "time" ) var l sync.Mutex var m *sync.Mutex func main() { m = new(sync.Mutex) go lock(1) time.Sleep(3 * time.Second) fmt.Printf("%s\n", "exit!") } func lock(i int) { println(i, "lock start") m.Lock() println(i, "lock") time.Sleep(3 * time.Second) m.Unlock() println(i, "unlock") }
标签:
原文地址:http://www.cnblogs.com/rojas/p/4401931.html