Metered concurrency: Difference between revisions

Content deleted Content added
Sonia (talk | contribs)
m →‎{{header|Go}}: small update to explanation text
Sonia (talk | contribs)
→‎{{header|Go}}: serialized output
Line 333:
 
import (
"fmtlog"
"os"
"time"
"sync"
)
 
var l = log.New(os.Stdout, "", 0)
 
func main() {
Line 375 ⟶ 378:
 
func student(a, r chan int, studied *sync.WaitGroup) {
a <- 0 // accquire
fmtl.Println("Studying...") // report per task descrption
time.Sleep(2e9) // sleep per task description
r <- 0 // release
studied.Done() // signal done
}</lang>
Output shows 10 students studying immediately, about a 2 second pause, 10 more students studying, then another pause of about 2 seconds before returning to the command prompt.