Tutorial by Examples

In this example we create a goroutine (a function running in a separate thread) that accepts a chan parameter, and simply loops, sending information into the channel each time. In the main we have a for loop and a select. The select will block processing until one of the case statements becomes tru...
So here, I have removed the for loops, and made a timeout by adding a second case to the select that returns after 3 seconds. Because the select just waits until ANY case is true, the second case fires, and then our script ends, and chatter() never even gets a chance to finish. // Use of the select...

Page 1 of 1