The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/utils/singleton_test.go

35 lines
420 B

package utils
import (
"sync"
"testing"
"time"
)
var NumThreads = 20
func TestSingleton(t *testing.T) {
var wg sync.WaitGroup
for i := 0; i < NumThreads; i++ {
wg.Add(1)
go func() {
defer wg.Done()
time.Sleep(time.Millisecond)
}()
}
wg.Wait()
n := 100
for i := 0; i < NumThreads; i++ {
wg.Add(1)
go func() {
defer wg.Done()
n++
time.Sleep(time.Millisecond)
}()
}
wg.Wait()
}