I have a question about multithreading (parallelism) in java. Indeed, I realized two program to compute a Mandelbrot Set :
The first launches n threads and each thread computes a part of the height of the Mandelbrot (Example : https://www.logre.eu/mediawiki/images/4/49/Mandelbrot_h_block.png).
The second launches a pool of n threads where each thread computes a line of pixels of the Mandelbrot (Example : https://www.logre.eu/mediawiki/images/f/f2/Mandelbrot_horizontal.png).
I made different profiling on a two cores machine and I don't understand why the first program is faster than the second if the number of threads (n) is greater than the number of cores. This is the opposite if the number of threads is lower than the number of cores.
Can anyone help me?
Note : Is there also a limit of threads to compute this program ?