1. func main() {
    2. // Allocate 1 logical processors for the scheduler to use
    3. runtime.GOMAXPROCS(1)
    4. // runtime.GOMAXPROCS(runtime.NumCPU())
    5. var wg sync.WaitGroup
    6. wg.Add(2)
    7. fmt.Println("Start Goroutines")
    8. go func() {
    9. defer wg.Done()
    10. for count := 0; count < 3; count++ {
    11. for char := 'a'; char < 'a'+26; char++ {
    12. fmt.Printf("%c ", char)
    13. }
    14. fmt.Println()
    15. }
    16. }()
    17. go func() {
    18. defer wg.Done()
    19. for count := 0; count < 3; count++ {
    20. for char := 'A'; char < 'A'+26; char++ {
    21. fmt.Printf("%c ", char)
    22. }
    23. fmt.Println()
    24. }
    25. }()
    26. wg.Wait()
    27. fmt.Println("Waiting To Finish")
    28. fmt.Println("\nTerminating Program")
    29. }

    A WaitGroup is a counting semaphore that can be used to maintain a record of running goroutines.