I'm creating a pooltable app that does a lot of image processing. I would like to divide some actions into separate threads. In my example I'd like to do 3 different threads:
1) searches for balls on image from camera
2) creates mode for projector (changes background image, does some perspective warp etc.)
3) searches for cue and does some mathematical operations
After this I`d like to connect all information from these 3 threads. When I do it like this:
new Thread(() -> {
tss.next()
.findBalls();
}).start();
new Thread(() -> {
tss.setProjectorMode(true);
try {
tss.projectorMode();
} catch (LineServiceException | FileNotFoundException | InterruptedException e) {
e.printStackTrace();
}
}).start();
new Thread(() -> {
// Dynamic mode
if (0 == configurableProperties.getGameMode()) {
tss
.findCue()
.makePredictions()
.detectCollision();
}
}).start();
this.table = tss.build();
then all 3 threads work separately but my tss.build doesn`t work well because it starts even if these threads are still in progress. How to make this "build" wait for all these threads to end?