This commit is contained in:
potassium 2025-07-08 23:44:31 +03:00
parent 5cfec0f2ef
commit d3b6541945

View File

@ -21,7 +21,7 @@ func tickReader(sem chan struct{}, ticker *time.Ticker, s string) io.Reader {
fmt.Fprintf(w, "%s with %v\n", s, t)
default: // try to comment this and then run :)
}
<-sem // add a ticket to the semaphore
<-sem // add a ticket to the semaphore
}
}()
return r
@ -46,7 +46,7 @@ func main() {
var (
wg sync.WaitGroup
semaphore = make(
chan struct{},
chan struct{},
1, // only one goroutine can do its thing
)
)