我的代码使用两个线程来调用相同的方法,但是该程序仅将第一个线程运行两次,而不是第二个线程,而且我不太确定为什么会这样。
ParallelImplementation(String repoPath1, String repoPath2, int revisions) throws IOException, GitAPIException {
git1 = Git.open(new File(repoPath1));
repo1 = FileRepositoryBuilder.create(new File(repoPath1));
git2 = Git.open(new File(repoPath2));
repo2 = FileRepositoryBuilder.create(new File(repoPath2));
allCommits1 = getAllCommits(git1);
allCommits2 = getAllCommits(git2);
childParentMap1 = getParentCommit(allCommits1);
childParentMap2 = getParentCommit(allCommits2);
mapIterator1 = childParentMap1.entrySet().iterator();
mapIterator2 = childParentMap2.entrySet().iterator();
ExecutorService pool1 = Executors.newFixedThreadPool(N_THREADS);
ExecutorService pool2 = Executors.newFixedThreadPool(N_THREADS);
new Thread(() -> {
try {
runParallelImplementation(repoPath1, pool1, git1, repo1, allCommits1, childParentMap1, mapIterator1);
} catch (GitAPIException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
new Thread(() -> {
try {
runParallelImplementation(repoPath1, pool2, git2, repo2, allCommits2, childParentMap2, mapIterator2);
} catch (GitAPIException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。