How to use Go concurrent Once
This article mainly explains "how to use Go concurrent Once". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use Go concurrent Once.
/ / execute the specified function ffunc (o * Once) Do (ffunc ()) only once for multiple calls
The fooOnce function of the example prints only once.
Func fooOnce () {fmt.Println ("execute only once")} func main () {var once sync.Once done: = make (chan int) for I: = 0; I < 10; iTunes + {go func (index int) {once.Do (fooOnce) done