How do I use Multithread to iterate a list with many records

118 Views Asked by At

I have a list with 200 records of an object. For each record in that list, I need to call an API REST (findOrderByID) to receive the complete data. The problem is that this process is taking more than 10 seconds and I want to use Multithreading to have a shorter time.

For iteration of my list.

// My list with ~200 registers
for (Order order: orderList.getID()) {
      OrderRestVO response = findOrderByID(order.getID); //Calling an API method
}

My question is, how do I utilize multi-threading to optimize my search?

0

There are 0 best solutions below