diff --git a/gos-concurrency-building-blocks/the-sync-package/pool/fig-sync-pool.go b/gos-concurrency-building-blocks/the-sync-package/pool/fig-sync-pool.go index f363c71..dcb1d5e 100644 --- a/gos-concurrency-building-blocks/the-sync-package/pool/fig-sync-pool.go +++ b/gos-concurrency-building-blocks/the-sync-package/pool/fig-sync-pool.go @@ -7,9 +7,12 @@ import ( func main() { var numCalcsCreated int + var m sync.Mutex calcPool := &sync.Pool{ New: func() interface{} { + m.Lock() numCalcsCreated += 1 + m.Unlock() mem := make([]byte, 1024) return &mem // <1> },