-5

I have a C++ loop that connects to a website and gets response from the website.

It looks something like this:

for(int i = 0; i < 1000; i++) {
 //connect to website and get response
}

the problem is, for each iteration of the loop, it takes about 4-5 seconds to connect to the website and get response, so only having 1 thread won't be fast enough. How would I, say, run this loop in 3 or 4 threads? (to speed it up)

BotHam
  • 17
  • 7

1 Answers1

0

You write what is wrong with your code yourself.

for(int i = 0; i < 1000; i++) {
 // **connect to website** and get response
}

reformat your program to

**connect to website**
for(int i = 0; i < 1000; i++) {
 // get response
}
** disconnect **
Surt
  • 15,501
  • 3
  • 23
  • 39