Warning
This repository is archived and no longer maintained.
mkill capped the number of OS threads reactively: a background daemon
polled ps once a second and reaped the surplus by spawning goroutines that
lock an OS thread and exit. That approach is fragile (it shells out to ps,
runs work on import, and kills threads it does not own).
Use golang.design/x/thread
instead. Its thread.Pool
caps threads by construction — work runs on a fixed set of owned threads,
with no subprocess and no import-time side effects:
p := thread.NewPool(10)
defer p.Terminate()
p.Go(func() { /* runs on one of 10 owned threads */ })Package mkill limits the number of threads in a Go program, without crash the whole program.
import "golang.design/x/mkill"
mkill.GOMAXTHREADS(10)
MIT © The golang.design Authors