On 3/21/06, Octavian Rasnita <[EMAIL PROTECTED]> wrote: > From: "Stephen Kratzer" <[EMAIL PROTECTED]> > > > I'm not too familiar with threads, but I'll give it a go. You're still > > executing the download() sub seventy times one after another rather than > > concurrently. The async function will created one new thread for the block > > following it. You might try a for loop which creates a new thread at each > > iteration. > > > > Maybe something like: > > > > my @threads; > > > > for (my $i = 1; $i <= 70; $i++) { > > $threads[$i] = threads->create(\&download, $i); > > $threads[$i]->join(); > > } > > > > I have tried this method, but it executes much slower than a simple for() > loop, with no threads at all. > > I have tried it using perl, v5.8.7 built for MSWin32-x86-multi-thread. > > Thank you. > > Teddy
That's because join waits for the thread to finish executing before it continues. You're still forcing linear execution. See my earlier example, and see the examples in perlthrtut. As for speed, there's no guarantee that threads will execute faster. That depends in large part on how well your OS supports threading, and your system configuration. If you're running out of RAM, bandwidth, disk space, processor power, or any other system resource, launching threads that will try to process in parallel may very well bog things down. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!