incCounter increments the package level counter variable.
(id int)
| 32 | |
| 33 | // incCounter increments the package level counter variable. |
| 34 | func incCounter(id int) { |
| 35 | // Schedule the call to Done to tell main we are done. |
| 36 | defer wg.Done() |
| 37 | |
| 38 | for count := 0; count < 2; count++ { |
| 39 | // Capture the value of Counter. |
| 40 | value := counter |
| 41 | |
| 42 | // Yield the thread and be placed back in queue. |
| 43 | runtime.Gosched() |
| 44 | |
| 45 | // Increment our local value of Counter. |
| 46 | value++ |
| 47 | |
| 48 | // Store the value back into Counter. |
| 49 | counter = value |
| 50 | } |
| 51 | } |