in reply to bug in threads::shared or is it just me?
or if some games are played with reference and dereference, a la return %{\%h};use strict; use warnings; use threads qw(yield); use threads::shared; use Data::Dumper; sub test { my %h : shared; for (1..3) { threads->new(sub { my($n) = @_; lock(%h); $h{$n} = rand(); threads->yield(); }, $_)->join(); } my %i = %h; return %i; } my %k = test(); print Dumper(\%k);
Unfortunately, I don't really have anything else useful to add.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|