Created
April 25, 2018 09:35
-
-
Save kaneshin/79b0b80286ec135cc00330874875139b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"regexp" | |
"sync" | |
) | |
var re1 = regexp.MustCompile("hoge.*") | |
var re2 = regexp.MustCompile("foo.*") | |
func main() { | |
v := map[int]int{} | |
var wg sync.WaitGroup | |
var mu sync.RWMutex | |
for i := 0; i < 100; i++ { | |
i := i | |
wg.Add(1) | |
go func() { | |
defer wg.Done() | |
for k := 0; k < 1000; k++ { | |
j := i * k | |
mu.Lock() | |
v[j] = k | |
mu.Unlock() | |
} | |
}() | |
} | |
wg.Wait() | |
for _, vv := range v { | |
fmt.Println(vv) | |
} | |
go func() { | |
re10 := re1.Copy() | |
re10.FindString() | |
}() | |
go func() { | |
re11 := re1.Copy() | |
re11.FindString() | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment