Source file test/fixedbugs/issue9321.go

     1  // run
     2  
     3  // Copyright 2014 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  import (
    10  	"bytes"
    11  	"runtime"
    12  	"runtime/pprof"
    13  	"sync"
    14  )
    15  
    16  func test() {
    17  	var wg sync.WaitGroup
    18  	wg.Add(2)
    19  	test := func() {
    20  		for i := 0; i < 10; i++ {
    21  			buf := &bytes.Buffer{}
    22  			pprof.Lookup("goroutine").WriteTo(buf, 2)
    23  		}
    24  		wg.Done()
    25  	}
    26  
    27  	go test()
    28  	go test()
    29  	wg.Wait()
    30  }
    31  
    32  func main() {
    33  	runtime.GOMAXPROCS(4)
    34  	for i := 0; i < 10; i++ {
    35  		test()
    36  	}
    37  }
    38  

View as plain text