This script basically just prints out the numbers 1 to 10, but it does so by spinning off each print statement into it’s own thread, using a go routine. You’ll notice the script also has a start and an end print statement, but because go are used, the end statement will be printed before and items (1-10) are printed.
The ending sleep allows the go routines to execute as they were being cut short by the main function finished, thus ending the programs life.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here