I have taught myself how to create and start/manage threads and I have tried to implement this in a mockup program. The mockup program iterates through a large integer arraylist. For each item in the list it increments the integer several times within a loop. The program takes 30 seconds to implement non-threaded.
I have added multiple threads to the mockup program, and fed each thread a section of the arraylist for processing. Each section is k elements long. The main UI thread contains a thread management loop whereby if a thread is determined to be done, it is fed another section of the list for processing.
I have experimented with different numbers of threads and different values for k, but the best performance I have been able to acheive is 7.5 seconds. My machine is an i7 (2600) quad core with hyperthreading (8 logical cores).
Should I be satisfied with this, or am I clearly not harnessing multithreading's full potential?
I eventually intend to apply this to a ray-tracing program I am writing. I have read a bit about backgroundworker and threadpool techniques, but they don't seem to offer much advantage to this application. Am I mistaken?
Thanks in advance.
Dave
I have added multiple threads to the mockup program, and fed each thread a section of the arraylist for processing. Each section is k elements long. The main UI thread contains a thread management loop whereby if a thread is determined to be done, it is fed another section of the list for processing.
I have experimented with different numbers of threads and different values for k, but the best performance I have been able to acheive is 7.5 seconds. My machine is an i7 (2600) quad core with hyperthreading (8 logical cores).
Should I be satisfied with this, or am I clearly not harnessing multithreading's full potential?
I eventually intend to apply this to a ray-tracing program I am writing. I have read a bit about backgroundworker and threadpool techniques, but they don't seem to offer much advantage to this application. Am I mistaken?
Thanks in advance.
Dave