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();
}
On Tuesday 21 March 2006 06:39, Octavian Rasnita wrote:
> Hi,
>
> I have tried the following script:
> use threads;
> my $threads = async {foreach(1 .. 70) {download($_)}};
>
> $threads->join();
> $threads->detach();
>
> sub download {...}
>
> This program takes the same amount of time to run like when not using
> threads, but a simple for() loop.
>
> How can I make it to run all the threads in the same time?
>
> Thank you.
>
> Teddy
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>