Multi Threading Java
java, multithreading, performance, processing
Solution
Instead of comparing the images every time, hash the images, save the hash, and then compare the hashes of each pair of messages. Since a hash is far smaller you can fit more into memory and cache, which should significantly speed up comparisons.
There is probably a better way to do the search for equality as well, but one option would be to stick all the hashes into an array then sort them by hash value. Then iterate over the list looking for adjacent entries that are equal. This should be `O(n*log(n))` instead of `O(n^2)` like your current version.
Problem
In my program I essentially have a method similar to: ``` for (int x=0; x<numberofimagesinmyfolder; x++){ for(int y=0; y<numberofimagesinmyfolder; y++){ compare(imagex,imagey); if(match==true){ System.out.println("image x matches image y"); } } } ``` So basically I have a folder of images and I compare all combinations of images...so compare image 1 against all images then image 2...and so on. My problem is when searching to see what images match, it takes a long time. I am trying to multithread this process. Does anyone have any idea of how to do this?