这是搜索这个HashMap最有效的方法还是可以通过多线程来改进? [关闭]

问题描述 投票:0回答:0

我有一个 HashMap (toSearch)。我正在该 HashMap (toMatch) 中寻找一个值。但在尝试比较 toSearch 和 toMatch 中的值之前,我需要除以 (toDivide)。

这是我当前的代码:

boolean found = false;
for (int i = 1; i <= 100; i++) {
  BigInteger result = toSearch.get(i).divide(toDivide);
  if (result.compareTo(toMatch) == 0) {
    found = true;
    break;
  }
}
                                
if (found) {
  doOtherWork();
}

这是在执行除法操作后在我的列表中搜索匹配项的最有效方法吗?或者有没有办法通过实施多线程来加快速度?

java multithreading threadpool executor
© www.soinside.com 2019 - 2024. All rights reserved.