|
|
| Welcome to the Monastery | |
| PerlMonks |
Re^3: multithreading sample neededby zentara (Archbishop) |
| on May 02, 2012 at 10:31 UTC ( #968418=note: print w/ replies, xml ) | Need Help?? |
|
Here is another way to slow things down for visualization. Add a delay in the thread sub. it seems that perl's idea of multithreading is just as good as calling the avarage subroutine :/ On a single cpu machine, that is true. In real world work, threading is more useful as a means of easily sharing variables between different code blocks running independently, using threads::shared. Otherwise, forking is usually a better parallel processing solution because of issues like memory reclamation, independence of IO, sharing objects, and a few others gotchas which threads occaisionally cause. For example, look how easy it is for the main thread and the child thread can share the array:
I'm not really a human, but I play one on earth. Old Perl Programmer Haiku ................... flash japh
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||