mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-28 15:56:04 +03:00
26 lines
343 B
Go
26 lines
343 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
concurrentCount := 5
|
||
|
sem := make(chan bool, concurrentCount)
|
||
|
|
||
|
for i := 0; i < 100; i++ {
|
||
|
sem <- true
|
||
|
go func(i int) {
|
||
|
dummyProcess(i)
|
||
|
<-sem
|
||
|
}(i)
|
||
|
}
|
||
|
time.Sleep(time.Second * 20)
|
||
|
}
|
||
|
|
||
|
func dummyProcess(i int) {
|
||
|
fmt.Printf("Process Dummy %v \n", i)
|
||
|
time.Sleep(time.Second)
|
||
|
}
|