Suppose you're designing a system where multiple goroutines need to communicate with each other asynchronously. Which concurrency construct in Go would you use and why?

  • Use a sync.Mutex to achieve mutual exclusion
  • Use atomic operations for shared memory access
  • Use channels due to their simplicity, safety, and built-in synchronization
  • Use semaphores for resource synchronization
Channels are a preferred choice for inter-goroutine communication in Go due to their safety features and built-in synchronization, simplifying the development process.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *