private class BatchUpdateThread implements Runnable {
String[] updateList;
Integer taskId;
public void run() {
int times = (updateList.length / 500) + 1;
List<String> list = Arrays.asList(updateList);
for (int i = 0; i < times; i++) {
int fromIndex = 500 * i;
List<String> subList = null;
if (list.size() > 500 * (i + 1)) {
subList = list.subList(fromIndex, 500 * (i + 1));
} else {
subList = list.subList(fromIndex, list.size());
}
int[] insertResult = getJdbcTemplate().batchUpdate(
subList.toArray(new String[subList.size()]));
logger.info(new StringBuilder(
"success number of BatchUpdateThread ").append(
i).append(" is: ").append(insertResult.length)
.toString());
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
create_index(taskId);
updateTaskStatus(taskId ,Constants.TASK_STATUS_ADDING);
}
}
String[] updateList;
Integer taskId;
public void run() {
int times = (updateList.length / 500) + 1;
List<String> list = Arrays.asList(updateList);
for (int i = 0; i < times; i++) {
int fromIndex = 500 * i;
List<String> subList = null;
if (list.size() > 500 * (i + 1)) {
subList = list.subList(fromIndex, 500 * (i + 1));
} else {
subList = list.subList(fromIndex, list.size());
}
int[] insertResult = getJdbcTemplate().batchUpdate(
subList.toArray(new String[subList.size()]));
logger.info(new StringBuilder(
"success number of BatchUpdateThread ").append(
i).append(" is: ").append(insertResult.length)
.toString());
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
create_index(taskId);
updateTaskStatus(taskId ,Constants.TASK_STATUS_ADDING);
}
}