第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

具有等待組和無緩沖通道的競爭條件

具有等待組和無緩沖通道的競爭條件

Go
嗶嗶one 2023-05-15 14:58:35
在這篇文章Understanding golang channels: deadlock中得到了我最初問題的(正確的)解決方案之后,我想出了一個(gè)稍微不同的解決方案(在我看來讀起來更好:// Binary histogram counts the occurences of each word.package mainimport (    "fmt"    "strings"    "sync")var data = []string{    "The yellow fish swims slowly in the water",    "The brown dog barks loudly after a drink ...",    "The dark bird bird of prey lands on a small ...",}func main() {    histogram := make(map[string]int)    words := make(chan string)    var wg sync.WaitGroup    for _, line := range data {        wg.Add(1)        go func(l string) {            for _, w := range strings.Split(l, " ") {                words <- w            }            wg.Done()        }(line)    }    go func() {        for w := range words {            histogram[w]++        }    }()    wg.Wait()    close(words)    fmt.Println(histogram)}它確實(shí)有效,但不幸的是在比賽中運(yùn)行它,它顯示了 2 個(gè)比賽條件:==================WARNING: DATA RACERead at 0x00c420082180 by main goroutine:...Previous write at 0x00c420082180 by goroutine 9:...Goroutine 9 (running) created at:  main.main()你能幫我了解比賽條件在哪里嗎?
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 109 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號