what is the golang equivalent of a Java synchronized() block?
问题 Java provides a very convenient idiom for synchronizing critical portions of code: synchronized(someObject) { // do something really important all by myself with nobody bothering me } Or public synchronized void doSomething() { // ... } What is the go equivalent? (A quick search reveals: golang.org/pkg/sync/ - which seems (maybe I'm wrong) a bit too low level for general use.) (Example of why I care about this: I need to send a message to multiple listeners via channels. Channels provide a