当前标签:线程池


go 的 Pool池对象-sync.Pool

go 的 Pool池对象-sync.Pool

2023-04-10 394 531
packagemain import( "fmt" "strconv" "sync" ) //在go中,原生的池化数据结构为sync.Pool,有三个方法: //New字段为一个方法,定义为func()interface{},在新建Pool时,定义好New字段,以供后续从池中获取对象时,如果当前池中无对象,则使