in reply to Inconsistent results with keys on thread shared hashes
Simpler:
for my $t (1..2) { threads->create(sub { while (1) { my $s = join '', sort keys %testOne; print "$t\t$s\n" if $s ne 'ABCDE'; } }); } sleep;
You are both reading and modifying the hash — specifically its iterator — in multiple threads. You need a lock.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inconsistent results with keys on thread shared hashes
by izomiac (Novice) on Aug 03, 2022 at 18:59 UTC | |
|
Re^2: Inconsistent results with keys on thread shared hashes
by Anonymous Monk on Aug 03, 2022 at 19:17 UTC |