AW: Problem with thread
[email protected] ("Sommer, Alexander, VF-DE")
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <0F1C223457E3EA40B943A34BDC29784A175BF3@DEDUS-WICL01M01.vf-de.internal.vodafone.com> |
Hello,
> Von: Ollivier Cédric
> I have a problem with my program. I would like to do some
> instructions in the same time by using thread.
> Why can I do for creating multithread in Perl ?
> That's my program.
> use threads;
> use Config;
>
> use Net::Ping;
>
> $Config{useithreads} or die
> "Recompilez Perl avec les threads activés pour faire
> tourner ce programme.";
>
> sub subping {
> my ($c) = @_;
> $p = Net::Ping->new();
> if ($p->ping($c)) {
> print "$host is alive.\n";
> }
> else {
> print "$host is not alive";
> }
> $p->close();
> }
>
> 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);
Gruß Alex