How can channels be used to synchronize Goroutines?

  • By sending data between Goroutines.
  • By blocking Goroutines until a condition is met.
  • By canceling Goroutines.
  • By delaying the execution of Goroutines.
Channels in Go can be used to synchronize Goroutines by blocking them until a condition is met. When a Goroutine attempts to read from an empty channel or write to a full channel, it will block until another Goroutine sends data to the channel or receives data from it. This synchronization mechanism ensures that Goroutines wait for each other, allowing for controlled execution order.
Add your answer
Loading...

Leave a comment

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