I may have misunderstood and if so please disregard.
But in my understanding of perl threads and the forks module is that
you don't pass shard variables as arguments. You just declare them
before creating the thread and use them because they're in scope. Here
is a bad example:
#!/usr/bin/perl
use strict;
use threads;
use threads::shared;
my $num : shared;
my $end : shared;
$num = 0;
$end = 0;
sub Boss {
lock $num;
$num = 5;
sleep 4;
lock $end;
$end = 1;
print "Boss: DONE!\n";
}
sub Worker {
while (!$end) {
sleep 1;
print $num. "\n";
}
print "Worker: DONE!\n";
}
my @hold;
push @hold, threads->new( \&Boss );
push @hold, threads->new( \&Worker );
$_->join foreach (@hold);
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/