Home > Article > Backend Development > Why Use a Pointer for WaitGroup.Done but Not for WaitGroup.Add and WaitGroup.Wait?
Pointers and Variables in WaitGroups Reference
In the sync package, the functions Add, Done, and Wait are all called by a pointer to a WaitGroup:
In the provided code snippet, the Done function is called using a pointer variable, while the Add and Wait functions are called using a variable (not a pointer).
However, all three functions are called on the same WaitGroup value.
The above is the detailed content of Why Use a Pointer for WaitGroup.Done but Not for WaitGroup.Add and WaitGroup.Wait?. For more information, please follow other related articles on the PHP Chinese website!