diff --git a/examples/cmd/gd-signal-handling/signal-handling.go b/examples/cmd/gd-signal-handling/signal-handling.go index 64c86a9..203f2b5 100644 --- a/examples/cmd/gd-signal-handling/signal-handling.go +++ b/examples/cmd/gd-signal-handling/signal-handling.go @@ -68,10 +68,13 @@ var ( ) func worker() { + LOOP: for { - time.Sleep(time.Second) - if _, ok := <-stop; ok { - break + time.Sleep(time.Second) // this is work to be done by worker. + select { + case <- stop: + break LOOP + default: } } done <- struct{}{}