Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for ExampleOnce (0.16 sec)

  1. src/sync/example_test.go

    			// Decrement the counter when the goroutine completes.
    			defer wg.Done()
    			// Fetch the URL.
    			http.Get(url)
    		}(url)
    	}
    	// Wait for all HTTP fetches to complete.
    	wg.Wait()
    }
    
    func ExampleOnce() {
    	var once sync.Once
    	onceBody := func() {
    		fmt.Println("Only once")
    	}
    	done := make(chan bool)
    	for i := 0; i < 10; i++ {
    		go func() {
    			once.Do(onceBody)
    			done <- true
    		}()
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 23 17:45:47 UTC 2024
    - 2.2K bytes
    - Viewed (0)
Back to top