Java多线程Jdbc,java - jdbctemplate.batchupdate是多线程还是并发? - 堆栈内存溢出
我已经使用Informix数据库在春季启动的最新版本中开发了一个应用程序。 有一些我想并行执行的任务。 我有以下问题。
jdbcTemplate.batchupdate()通过线程并行化查询,通过异步编程并发运行查询还是只是一个接一个地顺序执行它们?
private String query1, query2, query3;
public void executeQuery(JdbcTemplate jdbctemplate) {
jdbctemplate.batchupdate(query1, query2, query3)
}
我确实在线程中执行了它们,但是我发现性能没有差异。 知道为什么吗?
private void executeInThread(){
ExecutorService sommutExecutorService = Executors.newCachedThreadPool();
final CompletableFuture future1 = CompletableFuture.supplyAsync(() -> jdbcTemplate.update(query1), sommutExecutorService);
final CompletableFuture future2 = CompletableFuture.supplyAsync(() -> jdbcTemplate.update(query2), sommutExecutorService);
final CompletableFuture future3 = CompletableFuture.supplyAsync(() -> jdbcTemplate.update(query3), sommutExecutorService);
try {
CompletableFuture.allOf(future1, future2, future3).thenRun(() -> execute()).get();
} catch (InterruptedException | ExecutionException e) {
log(e.getMessage());
}finally {
sommutExecutorService.shutdown();
}
}