I have such function:
func TestDefer(lock sync.RWMutex, wait time.Duration) {
lock.Lock()
defer lock.Unlock()
// start goroutine
go func() {
time.Sleep(wait)
}()
}
I am eager to know when lock.Unlock()
will be executed? Is it synchronized with subroutine go func()
? Will it be waiting until it finishes?