Content deleted Content added
Tags: Reverted Mobile edit Mobile web edit |
ClueBot NG (talk | contribs) m Reverting possible vandalism by 91.197.226.117 to version by Hunan201p. Report False Positive? Thanks, ClueBot NG. (4180659) (Bot) |
||
Line 51:
<syntaxhighlight lang=Go>
// package pool
package pool
Line 62:
)
const
var (
Line 77:
// (e.g., TCP connection, SSL symmetric key acquisition, auth authentication are time-consuming)
func NewResource(id int) *Resource {
time.Sleep(500 *
return &Resource{resId: id}
}
Line 84:
func (r *Resource) Do(workId int) {
time.Sleep(time.Duration(rand.Intn(5)) * 100 * time.Millisecond)
log.Printf("using resource #%d finished work %d finish\n",
}
Line 150:
}
// Resources to return
defer p.GiveBackResource(res)
// Use resources to handle work
res.Do(workId)
Line 164:
wg.Wait()
}
</syntaxhighlight>
=== C# ===
|