Skip to content

Latest commit

 

History

History
34 lines (30 loc) · 506 Bytes

talk.md

File metadata and controls

34 lines (30 loc) · 506 Bytes

go trap

thread create

package main

import (
	"bufio"
	"net/http"
	_ "net/http/pprof"
	"os"
	"time"
)

// curl http://localhost:8080/debug/pprof/threadcreate

func main() {
	go func() {
		http.ListenAndServe(":8080", nil)
	}()
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < 100; i++ {
		go func(id int) {
			for {
				data, _, _ := reader.ReadLine()
				println(id, string(data))
			}
		}(i)
		time.Sleep(1 * time.Second)
	}
	println("create finish!")
	time.Sleep(5 * time.Second)
}