diff --git a/SynchRoGazer.go b/SynchRoGazer.go index ce75654..99446fd 100644 --- a/SynchRoGazer.go +++ b/SynchRoGazer.go @@ -16,6 +16,7 @@ import ( "os" "runtime" "sync/atomic" + "time" ) type HashFileResult struct { @@ -265,6 +266,11 @@ func main() { path := scanner.Text() atomic.AddInt64(&entries, 1) + for atomic.LoadInt64(&taskCount) >= (int64(*taskLimit) + 1) { + runtime.Gosched() + time.Sleep(time.Millisecond * 20) + } + atomic.AddInt64(&taskCount, 1) go func() { defer atomic.AddInt64(&taskCount, -1)