X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/src/sync
opt
/
golang
/
1.17.2
/
src
/
sync
/
📁
..
📁
atomic
📄
cond.go
(2.54 KB)
📄
cond_test.go
(5.07 KB)
📄
example_pool_test.go
(1 KB)
📄
example_test.go
(1.14 KB)
📄
export_test.go
(1.27 KB)
📄
map.go
(11.53 KB)
📄
map_bench_test.go
(6.3 KB)
📄
map_reference_test.go
(3.9 KB)
📄
map_test.go
(4.15 KB)
📄
mutex.go
(7.32 KB)
📄
mutex_test.go
(5.7 KB)
📄
once.go
(2.29 KB)
📄
once_test.go
(1.1 KB)
📄
pool.go
(8.57 KB)
📄
pool_test.go
(7.27 KB)
📄
poolqueue.go
(8.87 KB)
📄
runtime.go
(1.97 KB)
📄
runtime2.go
(507 B)
📄
runtime2_lockrank.go
(587 B)
📄
runtime_sema_test.go
(1.34 KB)
📄
rwmutex.go
(4.93 KB)
📄
rwmutex_test.go
(4.4 KB)
📄
waitgroup.go
(4.41 KB)
📄
waitgroup_test.go
(5.78 KB)
Editing: example_test.go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sync_test import ( "fmt" "sync" ) type httpPkg struct{} func (httpPkg) Get(url string) {} var http httpPkg // This example fetches several URLs concurrently, // using a WaitGroup to block until all the fetches are complete. func ExampleWaitGroup() { var wg sync.WaitGroup var urls = []string{ "http://www.golang.org/", "http://www.google.com/", "http://www.somestupidname.com/", } for _, url := range urls { // Increment the WaitGroup counter. wg.Add(1) // Launch a goroutine to fetch the URL. go func(url string) { // 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 }() } for i := 0; i < 10; i++ { <-done } // Output: // Only once }
Upload File
Create Folder