go语言时间问题

jiaweisi · 2017-12-26 07:01:08 · 1767 次点击

你的意思,不能 sleep?

#1
更多评论

for { var a int = 0 go f(p int){ time.Sleep(5time.Second) *p = 1 }(&a) xxxx xxxx }

#2
for { 
     var a int = 0 
     go func(p *int) { 
             time.Sleep(5time.Second) 
             *p = 1 
      } (&a) 
      xxxx 
      xxxx
 }

大概这样?

#3