I am looking for a way to run the following two lines of code with threads in parallel. I have seen some options, but they all go through to create a class Thread
, but I can not create the class in this case. I'm not sure how I can create the two threads and run in parallel:
list.forEach(reviewsList -> {
reviewWriter.persistReviews(reviewsList, activeTable);
});
saveInCoherence();
private void saveInCoherence() {
reviewsMap.forEach((keyMap, reviewList) -> {
...
}
}
In functional mode, what this will do is part go to Oracle
and it will do inserts and the other part will go to a cache and cache the same thing. The issue is that the process takes too long and for that reason I would like to put threads so that both processes go in parallel.