2 Einträge, 1 Seite |
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
35
36
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
use Thread;
use Data::Dumper;
my $href;
my $href_shared:shared;
$href = {
NAME => "name",
VNAME => "vname",
};
$href_shared = &share($href);
printf "main thread:%s\n",Dumper($href);
my $thread1 = Thread->new(\&function, 1);
my $thread2 = Thread->new(\&function, 2);
$thread1->join();
$thread2->join();
sub function {
my $param = shift;
print "thread $param started\n";
printf "href=%s\n",Dumper($href);
sleep(1);
print "thread $param ends\n";
}
2 Einträge, 1 Seite |