Thread parallele filehandles (24 answers)
Opened by Gast at 2006-08-28 12:57

esskar
 2006-08-28 13:10
#69276 #69276
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
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);
}


macht sinn, oder?

View full thread parallele filehandles