import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Input
Look at your loop:
for(int year = 11; year <= 13; year++){
for(int i = 1; i <= 350; i++){
//generating 1050 URLs at one shot
StringBuffer regNo = new StringBuffer("1111").append(year).append("111").append(String.format("%03d", i));
String url = "magicUrl" + regNo;
System.out.println(url);
worker = new MyRunnable(url, regNo.toString());
}
}
You're overwriting worker
each time through the loop, so by the time you get to executor.execute(worker);
, worker holds the last value you assigned to it, which will be the runnable created from the last url generated.
Try replacing the line worker = new MyRunnable(url, regNo.toString());
with executor.execute(new MyRunnable(url, regNo.toString()));
and see if that fixes it.