class RunAndRun implements Runnable {
private final int start, end;
public RunAndRun(int start, int end) {
this.start = start;
this.end = end;
Thread thread = new Thread(this);
thread.start();
}
public void run() {
for (int i = start; i < end; i++) {
SimpleModel simple = activity.simples.get(i);
CostModel model = new CostModel(simple);
costModels.add(model);
fillData(model);
progress++;
}
}
public void fillData(CostModel model) {
String data = "";
try {
URL url = new URL("http://............" + model.id + "&c=100");
URLConnection connection = url.openConnection();
InputStream stream = connection.getInputStream();
byte[] bytes = new byte[500];
stream.read(bytes);
data = new String(bytes);
} catch (Exception e) {
e.printStackTrace();
}