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
34
#!/usr/bin/perl -w
########################################
# Modules
use strict; # parameter Definition before use them
use Net::TFTP;
use threads;
use threads::shared;
#######################################
# Paramet Definition
my $ct=20; # counter parameter
my $tftp = Net::TFTP->new("IP-des-Servers", BlockSize => 1024);
###########################
# main programm
system("clear");
print "Starting main program\n";
my @threads;
for ( my $count = 1; $count <= $ct; $count++) {
my $t = threads->new(\&sub1, $count);
push(@threads,$t);
}
foreach (@threads) {
my $num = $_->join;
print "Download ready $num\n";
}
print "End of main program\n";
sub sub1 {
my $num = shift;
$tftp->get("RemoteFile", "LocalFile");
print "Download Nr.$num started\n";
# sleep $num;
# print "done with thread $num\n";
return $num;
}