Metered concurrency: Difference between revisions
Content deleted Content added
m →{{header|Go}}: small update to explanation text |
→{{header|Go}}: serialized output |
||
Line 333:
import (
"
"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
time.Sleep(2e9)
r <- 0
studied.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.
|