whatcanGOwrong

This commit is contained in:
2024-09-19 21:38:24 -04:00
commit d0ae4d841d
17908 changed files with 4096831 additions and 0 deletions
@@ -0,0 +1,29 @@
package main
import (
"math/rand"
"sync"
"time"
)
var globalvar1 int
func demo(id int, wait *sync.WaitGroup) {
for i := 0; i < 100; i++ {
sleep := rand.Intn(10) + 1
globalvar1 = globalvar1 + 1
time.Sleep(time.Duration(sleep) * time.Millisecond)
}
wait.Done()
}
func main() {
wait := new(sync.WaitGroup)
wait.Add(1)
wait.Add(1)
go demo(1, wait)
go demo(2, wait)
wait.Wait()
}