Hi,
folgender code: (5.10)
spuckt folgendes aus:
Wie man sieht fehlt hier die Ausgabe aus zeile 43, nur warum?
Die Zeilen 47, 51 und 54 werden schliesslich auch ausgegeben?!
- MfG Keks
folgender code: (5.10)
Code:
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
no warnings 'uninitialized';
use threads;
use threads::shared;
my $shared_scalar :shared = "Ich will";
my $shared_tid :shared = undef;
my @shared_array :shared = ();
my @array = ();
$shared_array[0] = " mehr Kekse!\n";
my $thread = threads -> create(sub
{
print $shared_scalar, $shared_array[0];
}
);
sleep 1;
my $tid = $thread -> tid;
print $tid, "\n";
print threads -> object($tid), "\n";
$shared_tid = $tid;
print threads -> object($shared_tid), "\n";
$shared_array[1] = $tid;
print threads -> object($shared_array[1]), "\n";
$_ = $shared_array[1];
print threads -> object($_), "\n";
$array[0] = $tid;
print threads -> object($array[0]), "\n";
print $shared_array[1];
$thread -> join;
spuckt folgendes aus:
Code:
Ich will mehr Kekse!
1
threads=SCALAR(0x...)
threads=SCALAR(0x...)
threads=SCALAR(0x...)
threads=SCALAR(0x...)
1
Wie man sieht fehlt hier die Ausgabe aus zeile 43, nur warum?
Die Zeilen 47, 51 und 54 werden schliesslich auch ausgegeben?!
- MfG Keks