Hi,
I have some variables blessed with one Class.
In one of the member functions of that Class, I created thread.
I tried to access the Member variables directly from that Thread function as shown in the code below:
I am unable to get the blessed variables data in the thread function.
Can someone please let me know how to access them in thread function.
package PKG1;
sub New {
my($port, $ipadd) = @_;
:
:
my $self = {
ipaddress => $ipadd,
port => $to_port,
};
bless($self, $class);
}
sub Start {
my ($self) = @_;
my $tid = threads->new(\&threadFunc);
$tid->join();
}
sub threadFunc{
my($self) = @_;
my($port, $ip);
$ip = $self->{ipaddress};
$port = $self->{port};
}
1;