> > for ($i=1;$i<255;$i++)
> > {
> > $host="10.10.10."."$i";
> > my $thread = threads->create(threads,subping($host));
> > }
>
> here I would say, you should write:
> my $thread1 = threads->new(\&subping, $host);
>
So, what happens to the $thread variable in each iteration of the loop?
Does it go out of scope and get destroyed? Normally, if something else
references $thread, it does not get destroyed. But in this case, what
references $thread? I'm not sure.
The code I've written code might look like this:
for ($i=1;$i<255;$i++) {
$host="10.10.10."."$i";
push @threads, threads->create(threads,subping($host));
}
Then somewhere else:
foreach my $thread (@threads) {
$thread->join();
}