On Monday, October 23, 2017 at 7:04:53 PM UTC-4, Keith Randall wrote:
>
> They are the lock count for the given lock.  Imagine each lock keeps track 
> of how many times it has been acquired.
> There is a happens-before edge from an unlock to a lock only if the unlock 
> has a lower count (i.e. was earlier than) than the lock.
>

get it. Thanks.
 

>
>
> On Mon, Oct 23, 2017 at 3:43 PM, T L <tapi...@gmail.com <javascript:>> 
> wrote:
>
>> Thanks all for the explanations.
>>
>> I still have one question, which has been mentioned above.
>>
>> > For any sync.Mutex or sync.RWMutex variable l and *n* < *m*, call *n* 
>> of l.Unlock() happens before call *m* of l.Lock() returns. 
>>
>> What are the "n" and "m" here?
>>
>> On Saturday, October 21, 2017 at 5:01:08 PM UTC-4, T L wrote:
>>>
>>> package main
>>>
>>> import "fmt"
>>> import "sync"
>>> import "sync/atomic"
>>>
>>> func main() {
>>>     var a, b int32 = 0, 0
>>>     
>>>     go func() {
>>>         a = 1
>>>         atomic.AddInt32(&b, 1)
>>>     }()
>>>     
>>>     for {
>>>         if n := atomic.LoadInt32(&b); n == 1 {
>>>             fmt.Println(a) // always print 1?
>>>             break
>>>         }
>>>     }
>>>     
>>>     //======================
>>>     
>>>     var x, y int32 = 0, 0
>>>     var m sync.Mutex
>>>     
>>>     go func() {
>>>         x = 1
>>>         m.Lock()
>>>         y++
>>>         m.Unlock()
>>>     }()
>>>     
>>>     for {
>>>         m.Lock()
>>>         n := y
>>>         m.Unlock()
>>>         if n == 1 {
>>>             fmt.Println(x) // always print 1?
>>>             break
>>>         }
>>>     }
>>> }
>>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/golang-nuts/mSD7u1oEhSk/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> golang-nuts...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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