I am new to Java concurrency, so I am asking what is the best way to do these things:
I have a static method that matches the helper image inside the image. It looks like this:
public static Point match(final BufferedImage subimage, final BufferedImage image)
The method returns null if nothing is matched, otherwise it returns a Match Point.
Now I have 40 different helper images for one (large) image, which I want to combine in parallel. Every second I get a new (large) image in which I need to search again and again for these 40 smaller images. I need the return values of each call to match the method at the end of the match task in my main task, so I can analyze it. In addition, for this task I need to use as many processor cores as possible.
How can i do this? I read a lot about ExecutorService, Task, Runnable, etc. Most examples show how to print something on the console in parallel. I am really confused how I should go according to my scenario: how to convey values and how to get results? What should the layout of the class (s) look like? Also, I have no idea how to go if I create 40 tasks per second (it will take some time to configure the task, right?)
The code would be very helpful to explain this :)
source share