Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for TestWaitGroupRace (0.17 sec)

  1. src/sync/waitgroup_test.go

    		if err != "sync: negative WaitGroup counter" {
    			t.Fatalf("Unexpected panic: %#v", err)
    		}
    	}()
    	wg := &WaitGroup{}
    	wg.Add(1)
    	wg.Done()
    	wg.Done()
    	t.Fatal("Should panic")
    }
    
    func TestWaitGroupRace(t *testing.T) {
    	// Run this test for about 1ms.
    	for i := 0; i < 1000; i++ {
    		wg := &WaitGroup{}
    		n := new(int32)
    		// spawn goroutine 1
    		wg.Add(1)
    		go func() {
    			atomic.AddInt32(n, 1)
    			wg.Done()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 14 17:38:39 UTC 2021
    - 3K bytes
    - Viewed (0)
Back to top