#! perl -slw
use strict;
use threads;
use threads::shared;
my @myarray : shared;
sub pid { lock @myarray; push @myarray, $_[ 0 ]; }
threads->new( \&pid, $_ )->detach for 1 .. 3;
sleep 2;
print "@myarray";
__END__
[23:30:52.15] P:\test>417163
1 2 3
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail
"Time is a poor substitute for thought"--theorbtwo
"Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
| [reply] [d/l] |