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.
In reply to Re: Inconsistent results with keys on thread shared hashes
by ikegami
in thread Inconsistent results with keys on thread shared hashes
by izomiac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |