golang试题-关于Golang的goroutine,下面哪些说法是正确的?

package main

import (
    "fmt"
    "sync"
)

var count int

func increment(wg *sync.WaitGroup) {
    count++
    wg.Done()
}

func main() {
    var wg sync.WaitGroup
    for i := 0; i < 100; i++ {
        wg.Add(1)
        go increment(&wg)
    }
    wg.Wait()
    fmt.Println(count)
}

网友评论0