package main
import (
"fmt"
"sync"
"time"
)
func main() {
var total =0
var mux sync.Mutex
for i:=0; i<10; i++{
go func() {
for {
mux.Lock()
total += 1
fmt.Println("total=%d",total)
time.Sleep(time.Millisecond)
mux.Unlock()
}
}()
}
time.Sleep(time.Second)
fmt.Println("last total=%d",total)
}