package main import ( "github.com/cockroachdb/cockroach/util/stop" ) func main() { stopper := stop.NewStopper() stopper.AddWorker() stopper.RunWorker(func() { // Do some work here... }) stopper.Stop() }
package main import ( "github.com/cockroachdb/cockroach/util/stop" ) func main() { stopper := stop.NewStopper() for i := 0; i < 5; i++ { stopper.AddWorker() stopper.RunWorker(func() { // Do some work here... }) } stopper.Stop() }This example creates a new `Stopper` and adds five workers to it. Each worker runs a function that performs some work. The program terminates by calling the `Stop` method on the `Stopper`.