diff --git a/SynchRoGazer.go b/SynchRoGazer.go index 3a43150..ad85a7f 100644 --- a/SynchRoGazer.go +++ b/SynchRoGazer.go @@ -19,6 +19,7 @@ import ( "os" "runtime" "sync/atomic" + "time" ) type HashFileResult struct { @@ -287,6 +288,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)