Always have x number of goroutines running at any time

前端 未结 7 1808
鱼传尺愫
鱼传尺愫 2020-12-13 00:10

I see lots of tutorials and examples on how to make Go wait for x number of goroutines to finish, but what I\'m trying to do is have ensure there are always x number running

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 00:44

    1. Create channel for passing data to goroutines.
    2. Start 20 goroutines that processes the data from channel in a loop.
    3. Send the data to the channel instead of starting a new goroutine.

提交回复
热议问题