1

I created a map that is safe for concurrent access, in each of the operations (or compound operations) I wrapped the operation with a lock.

func .. {
  mu.Lock()
  defer mu.Unlock()
  ..
}

Could I use goroutines for this also? Should I be using goroutines?

3

1 Answer 1

1

This is no longer necessary in Go 1.9 and later. There is already a map implementation for concurrent use sync.Map.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.