未验证 提交 c5ee00bf 编写于 作者: kimmking's avatar kimmking 提交者: GitHub

adjust threadpool size in asyncLoad (#4828)

上级 6541936a
......@@ -101,7 +101,7 @@ public final class SchemaMetaDataLoader {
private static Map<String, TableMetaData> asyncLoad(final DataSource dataSource,
final int maxConnectionCount, final List<String> tableNames, final List<List<String>> tableGroups) throws SQLException {
Map<String, TableMetaData> result = new ConcurrentHashMap<>(tableNames.size(), 1);
ExecutorService executorService = Executors.newFixedThreadPool(maxConnectionCount);
ExecutorService executorService = Executors.newFixedThreadPool(Math.min(tableGroups.size(), maxConnectionCount));
Collection<Future<Map<String, TableMetaData>>> futures = new LinkedList<>();
for (List<String> each : tableGroups) {
futures.add(executorService.submit(() -> load(dataSource.getConnection(), each)));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册