let group = DispatchGroup()for _ in 0...999 { group.enter() URLSession.shared.dataTask(with: …) { _, _, _ in … group.leave() }.resume()}group.wait()