|< 1 2 3 >| | 25 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl -w
use strict;
use threads;
sub SubFunction;
print "main: ".threads->tid."\n";
my $thread;
$thread = threads->new(\&SubFunction, "localhost");
$thread = threads->new(\&SubFunction, "localhost");
$thread = threads->new(\&SubFunction, "localhost");
$thread = threads->new(\&SubFunction, "localhost");
$thread = threads->new(\&SubFunction, "localhost");
# loop through threads and wait for remaining
foreach $thread (threads->list) {
#print "remaining threads: ".threads->list."\n";
if ($thread->tid && !threads::equal($thread, threads->self)) {
$thread->join; # join childs only
}
}
sub SubFunction {
print "- thread: ".threads->tid."\n";
#system("ping $_[0]");
my $fh;
open($fh, '-|', "ping.exe $_[0]") or die "couldn't open pipe!";
print while (<$fh>);
close($fh);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl -w
use strict;
use threads;
sub SubFunction;
print "main: ".threads->tid."\n";
threads->new(\&SubFunction, "localhost");
threads->new(\&SubFunction, "localhost");
threads->new(\&SubFunction, "localhost");
threads->new(\&SubFunction, "localhost");
threads->new(\&SubFunction, "localhost");
# loop through threads and wait for remaining
foreach my $thread (threads->list) {
#print "remaining threads: ".threads->list."\n";
if ($thread->tid && !threads::equal($thread, threads->self)) {
$thread->join; # join childs only
}
}
sub SubFunction {
print "- thread: ".threads->tid."\n";
#system("ping $_[0]");
my $fh;
open($fh, '-|', "ping.exe $_[0]") or die "couldn't open pipe!";
print while (<$fh>);
close($fh);
}
|< 1 2 3 >| | 25 Einträge, 3 Seiten |