Threads and garbage collection work particularly well together, since garbage collection can
eliminate programmer effort to decide when the last thread using an object has stopped using it.
https://golang.org/src/runtime/chan.go 需要看这个 At a high level, a chan is a struct holding a buffer and a lock. Sending on a channel involves acquiring the lock, waiting (perhaps releasing the CPU) until some thread is receiving, and handing off the message. Receiving involves cquiring the lock and waiting for a sender. 这是阻塞式写法?
Goroutines run in the same address space, so access to shared memory must be synchronized. The sync package provides useful primitives, although you won't need them much in Go as there are other primitives.
eliminate programmer effort to decide when the last thread using an object has stopped using it.
https://golang.org/src/runtime/chan.go 需要看这个 At a high level, a chan is a struct holding a buffer and a lock. Sending on a channel involves acquiring the lock, waiting (perhaps releasing the CPU) until some thread is receiving, and handing off the message. Receiving involves cquiring the lock and waiting for a sender. 这是阻塞式写法?
Goroutines run in the same address space, so access to shared memory must be synchronized. The sync package provides useful primitives, although you won't need them much in Go as there are other primitives.