add mutex lock

This commit is contained in:
onyx 2024-01-02 06:58:03 +00:00
parent cc452c76a4
commit 9ba5ad695e

View File

@ -6,6 +6,7 @@ import (
) )
var wg sync.WaitGroup var wg sync.WaitGroup
var mu sync.Mutex
const UNLIMITED = -1 const UNLIMITED = -1
@ -68,7 +69,9 @@ func two(lines []string) int {
wg.Add(1) wg.Add(1)
go func(i int) { go func(i int) {
defer wg.Done() defer wg.Done()
mu.Lock()
seedRanges = append(seedRanges, nextTransform(0, []bound{newBound(seeds[i], seeds[i]+seeds[i+1]-1)})...) seedRanges = append(seedRanges, nextTransform(0, []bound{newBound(seeds[i], seeds[i]+seeds[i+1]-1)})...)
mu.Unlock()
}(i) }(i)
} }