I would like to point out that the example code you refer to is meant to 
illustrate a specific behavior of locks. It is *not* necessarily intended 
to be an example of good style. As a "new gopher" I would avoid this idiom. 
If you did use this, some significant commenting would be needed. 

Also, what blog post are you referring to?

- Jake

On Tuesday, March 13, 2018 at 9:27:08 AM UTC-4, 郎凯 wrote:
>
> var l sync.Mutex
> var a string
>
> func f() {
> a = "hello, world"
> l.Unlock()
> }
>
> func main() {
> l.Lock()
> go f()
> l.Lock()
> print(a)
> }
>
> I'm a new gopher, reading a blog about lock and having a problem, in 
> general , we use sync.Mutex in pairs, in the above code why could it call 
> lock two times  in main.
> Any help is Appreciated.
> Thanks in advanced.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to