Hackerboard Wiki HaboBlog
Hackerboard bei Facebook Hackerboard bei Google+ Hackerboard bei Twitter

[HaBo]

 
Code Kitchen Allgemeines Coder-Forum rund um das Programmieren eigenständiger, ausführbarer Programme.

threads::shared | threads->object() arbeitet nicht mit "shared" arrays

Diskussion: threads::shared | threads->object() arbeitet nicht mit "shared" arrays im Forum Code Kitchen, in der Kategorie Software Home; Anzeige Hi, folgender code: (5.10) code     Code: #!/usr/bin/perl use strict; use warnings FATAL => 'all'; no warnings 'uninitialized'; ...

Antwort
Alt 23.08.08, 14:11   #1 (permalink)
 
Registriert seit: 06.01.07
keksinat0r Leistung: Facit NTK
Likes: 0
Standard threads::shared | threads->object() arbeitet nicht mit "shared" arrays

Anzeige

Hi,

folgender code: (5.10)

code   
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:
ausgabe   
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
keksinat0r ist offline   Mit Zitat antworten
Antwort
   
- Anzeige -

Werbung ist gerade online    

[HaBo] » Software Home » Code Kitchen » threads::shared | threads->object() arbeitet nicht mit "shared" arrays
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind aus
Pingbacks sind aus
Refbacks sind aus


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
forks(::shared) vs SIGINT keksinat0r (Web-) Design und webbasierte Sprachen 0 30.08.09 14:17
perl threads::shared - diverse Probleme mit "shared" variablen keksinat0r Code Kitchen 4 22.02.09 18:43
VirtualBox und Shared Folders GambaJo Applikationen 4 01.01.08 16:13
shared memory CPU8080 Windows 3 23.05.06 19:10
shared memory grafikkarte a?+b?=c? Hardware Probleme 1 02.08.05 14:17


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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61