ich hab mal einen code vorbereitet um zu demonstieren, was ich genau will.
ich will jetzt von einem anderen thread aus auf die methode "foo" von $t zureifen.
Code:
#!/bin/perl -w
use strict;
use threads qw/yield/;
use Data::Dumper;
package Foo;
sub new {
my($class) = @_;
bless {}, $class;
}
sub foo {
print "foo!\n";
}
package main;
my $t;
sub th1 {
$t = Foo->new();
}
sub th2 {
print $t->foo();
}
#use Test::More tests => 1;
my $th_1 = threads->new(\&th1);
my $th_2 = threads->new(\&th2);
$th_1->join();
$th_2->join();
Lesezeichen