Skip to content

Commit 043358e

Browse files
JesseJesse
authored andcommitted
add module folders
1 parent dd95456 commit 043358e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/module2/mutex/main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"sync"
6+
"time"
7+
)
8+
9+
func main() {
10+
loopFunc()
11+
time.Sleep(time.Second)
12+
}
13+
14+
func loopFunc() {
15+
lock := sync.Mutex{}
16+
for i := 0; i < 3; i++ {
17+
// go func(i int) {
18+
lock.Lock()
19+
defer lock.Unlock()
20+
fmt.Println("loopFunc:", i)
21+
// }(i)
22+
}
23+
}

0 commit comments

Comments
 (0)