izomiac has asked for the wisdom of the Perl Monks concerning the following question:
I'm running this with Strawberry Perl on Windows, and my application uses threads so the Tk GUI doesn't freeze. I want to be able to use a lot of worker threads for a CPU-bound genetic sorting algorithm. Is this a bug in perl, or have I misunderstood something?#!/usr/bin/perl use strict; use warnings; $|=1; use threads; use threads::shared; my %testOne :shared = (A => 1, B => 2, C => 3, D => 4, E => 5); my %testTwo = (A => 1, B => 2, C => 3, D => 4, E => 5); my $inc :shared = 1; do { threads->create(sub { while (1){ my $i = join('', sort keys %testOne); my $j = join('', sort keys %testTwo); print "$inc-1\t$i\n" if ($i ne 'ABCDE'); print "$inc-2\t\t$j\n" if ($j ne 'ABCDE'); } }); } while (sleep 5 && $inc++ && $inc < 100);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Inconsistent results with keys on thread shared hashes
by ikegami (Patriarch) on Aug 03, 2022 at 06:11 UTC | |
by izomiac (Novice) on Aug 03, 2022 at 18:59 UTC | |
by Anonymous Monk on Aug 03, 2022 at 19:17 UTC | |
Re: Inconsistent results with keys on thread shared hashes
by Anonymous Monk on Aug 03, 2022 at 10:42 UTC | |
by izomiac (Novice) on Aug 03, 2022 at 19:12 UTC |