-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path09_counter.go
More file actions
34 lines (30 loc) · 806 Bytes
/
09_counter.go
File metadata and controls
34 lines (30 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Třicátá první část
// Sledování vybraných metrik služeb naprogramovaných v jazyku Go
// https://www.root.cz/clanky/sledovani-vybranych-metrik-sluzeb-naprogramovanych-v-jazyku-go/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů ze třicáté první části:
// https://github.com/tisnik/go-root/blob/master/article_31/README.md
//
// Demonstrační příklad číslo 9:
// Čítač zvyšovaný ve více vláknech bez synchronizace.
package main
import (
"fmt"
"time"
)
func main() {
var cnt int = 0
for i := 0; i < 1000; i++ {
go func() {
cnt++
}()
}
time.Sleep(1000 * time.Millisecond)
fmt.Printf("%d\n", cnt)
}