I was trying to solve Euler Project. Gist here. Yes, I get it, there is no algorithm used - I am not trying to. The question is, the 2nd file is using an ExecutorService to find the values - I understand that the result will not be correct but it is crawling compared to single threaded one. I thought creating threads itself might have overhead reduced the pool size to 4 (I have an eight core processor) but that did nothing.
Earlier I had also used similar approach to significantly speed up thumbnail generation using multiple threads. But I am not able to understand what might be causing the slowness of this particular case. I am not trying to get the correct solution - I understand that I should do that first and then attempt anything else. What is that I doing it wrong. I am not coming here with intention to find a solution to the problem but I want to understand why is it slow. I have used static variables that are accessed by Threads. Could that be an issue ?
ExecutorService, so hopefully all threads should live until a number is found - I kill the program after 5-6 minutes of execution since it is running very slowly. Should I run it longer ? But calls in a thread lasts only a few milliseconds around 1-2. Blocked on IO - Now I only have one line ofSystem.out.println- will that still matter that tell the count I have reached in checking factor ? It still runs much slower compared to single-threaded. - ykesh