1

我需要您的帮助,这是一段发出请求的代码https://play.golang.org/p/1_FOY8BTZND,每个请求都有自己的延迟 1 个请求正在等待第二个完成,即 wg .Done(),返回:

ID: 0, Name: Test #1, Sleep: 5ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 0, Name: Test #1, Sleep: 5ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 0, Name: Test #1, Sleep: 5ns
ID: 1, Name: Test #2, Sleep: 1ns

如何让第一个请求不等待第二个,而是线性执行,只等待其组完成,返回:

ID: 0, Name: Test #1, Sleep: 5ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 0, Name: Test #1, Sleep: 5ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
ID: 1, Name: Test #2, Sleep: 1ns
4

0 回答 0