in reply to Re^3: threads::shared - when to lock a hash ?
in thread threads::shared - when to lock a hash ?
There is one iterator per shared object, which is why I mentioned earlier that if other threads do each/keys/value too, it will affect the resultuse threads; use threads::shared; my $x : shared; for (0..9) { threads->new(sub { while (1) { $x = $_[0]; die unless $x =~ /^\d$/; } }, $_ ); } sleep;
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: threads::shared - when to lock a hash ?
by ikegami (Patriarch) on Oct 17, 2011 at 06:57 UTC | |
by choroba (Cardinal) on Oct 17, 2011 at 10:30 UTC |