I want to improve the efficiency of my program and I think adopting a multi-threaded approach may help.
My program converts a list of values from one currency to another using a currency converter web service. Currently my code iterates over the list and invokes the service on each value one after another, as follows:
code:
Integer[] originalValues = {5.8, 7.3, 12.6};
Integer[] convertedValues = new Integer[originalValues.length];
for(int i = 0; i < originalValues.length; i++)
{
convertedValues[i] = currencyWebServicePort.getConvertedValue( originalValues[i] );
}
Is it possible/a better idea to use threads for such a scenario, e.g.for each value in our originalValues list, create a thread that invokes the currency converter web service synchronously? If yes, then is there a maximum number of threads allowed to created?
I apologise if these are basic questions, but I am new to using threads. I would also appreciate if you could point me to relevant articles/forums focused on using threads together with web services.