Umbranocturna
How to efficiently use Threads and locks
I'm writing a short program that computes the mandelbrot set.
I have implemented threads, but ts my first time using them and i'm a little confused.
There probably is a better way to create, start and join threads, but i wasn't able to find anything better.
Its not clear to me how threads work overall. I have a 16 thread CPU and using 8 threads bumped the usage from 10% to 30%.
How can i find out what a good number of threads to use is?
I had to lock the bitmap so that the threads wouldn't try to write at the same time.
But i feel like this isn't the best practise as the threads will wait on one another fairly often.
I wanted to save the X Y Color values in some structure and write all at once after joining, but was not yet able to come up with anything.
Any ideas?
20 replies