File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,11 +4,15 @@ package main
44
55import (
66 "fmt"
7+ "runtime"
78 "sync"
89)
910
1011// main is the entry point for all Go programs.
1112func main () {
13+ // Allocate 1 logical processor for the scheduler to use.
14+ runtime .GOMAXPROCS (1 )
15+
1216 // wg is used to wait for the program to finish.
1317 // Add a count of two, one for each goroutine.
1418 var wg sync.WaitGroup
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package main
44
55import (
66 "fmt"
7+ "runtime"
78 "sync"
89)
910
@@ -12,6 +13,9 @@ var wg sync.WaitGroup
1213
1314// main is the entry point for all Go programs.
1415func main () {
16+ // Allocate 1 logical processors for the scheduler to use.
17+ runtime .GOMAXPROCS (1 )
18+
1519 // Add a count of two, one for each goroutine.
1620 wg .Add (2 )
1721
Original file line number Diff line number Diff line change @@ -10,14 +10,14 @@ import (
1010
1111// main is the entry point for all Go programs.
1212func main () {
13+ // Allocate two logical processors for the scheduler to use.
14+ runtime .GOMAXPROCS (2 )
15+
1316 // wg is used to wait for the program to finish.
1417 // Add a count of two, one for each goroutine.
1518 var wg sync.WaitGroup
1619 wg .Add (2 )
1720
18- // Allocate two logical processors for the scheduler to use.
19- runtime .GOMAXPROCS (2 )
20-
2121 fmt .Println ("Start Goroutines" )
2222
2323 // Declare an anonymous function and create a goroutine.
You can’t perform that action at this time.
0 commit comments