Here is another solution that does not use any external resources aside from java.util
Instead of using
public static List<Map<String,Object>> stockSymbolsListMap = new ArrayList<Map<String,Object>>();
I used
private static ArrayList<bleh> eh = new ArrayList<bleh>();
Step 1. Create array
for(int i = 0; i < 450; i++){
eh.add(new bleh());
}
Step 2. Partition the list (Did not spend much time on this, so the code is a tad messy)
Let BLOCK_SIZE = the size of each parition
int listAmount;
if(eh.size()%BLOCK_SIZE != 0)
listAmount = eh.size()/BLOCK_SIZE + 1;
else
listAmount = eh.size()/BLOCK_SIZE;
List<bleh>[] lists = new List[listAmount];
for(int i = 1; i <= listAmount; i++){
if(i * BLOCK_SIZE < eh.size()){
lists[i - 1] = eh.subList( (i - 1) * BLOCK_SIZE, eh.size());
}
else{
lists[i - 1] = eh.subList( (i - 1) * BLOCK_SIZE, i * BLOCK_SIZE);
}
}
Step 3. Run the lists concurrently
ExecutorService executor = Executors.newCachedThreadPool();
for(List<bleh> list : lists){
executor.execute(new MyThread(list));
}
The MyThread class I used is as such
private static class MyThread implements Runnable{
private List<bleh> eh = null;
public MyThread(List<bleh> list){
eh = list;
}
@Override
public void run(){
System.out.println("SOME THREAD");
for(bleh meh : eh){
System.out.print(meh.toString());
}
}
}
To use Executors you will need to import
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
or simply
import java.util.concurrent.*;
UPDATE
You may want to also scale the amount of threads created in accordance to the amount of threads available in which the following link should be of use, How to Scale Threads According to CPU Cores.