in reply to Trouble implementing threads

I dont think that the threads I have implemented works properly, because there's no visible improvement in the script as used without threads.

Do you have a multi-core computer setup to run as multiple processors? If not, if you essentially have a single cpu, you can only process 1 thread at a time, and there will be no speed improvement over just running your math sequentially in a single subroutine. Its a common misconception that threads speed up parallelized routines on single cpu machines. In some cases they can help, like if there are multiple socket calls out to the internet, but in general text processing or number crunching no gain is made. You probably actually slow things down by threading on a single cpu computer, due to the overhead that threads impose.

Threads still can be useful on single cpu machines, but it is not for speed improvements; it is for things like inter-process communication and making routines non-blocking.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Trouble implementing threads
by saranrsm (Acolyte) on Oct 20, 2011 at 14:24 UTC
    I am having a 64 bit intel core 2 quad processor with 4 GB RAM, wont that be enough??