Skip to content

Instantly share code, notes, and snippets.

@pacuna
Created June 15, 2020 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacuna/e26ff304fb1657172f3a157e412e1c65 to your computer and use it in GitHub Desktop.
Save pacuna/e26ff304fb1657172f3a157e412e1c65 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sortedlist/simplelist"
"sync"
)
func main() {
l := simplelist.New()
var wg sync.WaitGroup
for i := 0; i < 200; i++ {
wg.Add(1)
go func(it int) {
item := []byte(string(it))
l.Add(item)
wg.Done()
}(i)
}
wg.Wait()
fmt.Println(l.Size()) // 1st run: 199, 2nd run: 198, 3rd run: 200...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment