konnjuta has asked for the wisdom of the Perl Monks concerning the following question:
Can someone explains why this code only runs under one CONCURRENT thread.
perl -Mthreads -Mbignum -le '$_->join foreach map async { 2**859433-1 } , 1..2'Process/threads listing
root@blackjack:/usr/bin# ps -efL | grep perl root 10694 8844 1 1 0 10:32:34 pts/1 0:00 grep pe +rl usr 10679 9335 1 1 3 10:32:28 pts/2 0:06 perl -M +threads -Mbignum -cle $_->join foreach map async { 2**859433-1 } , 1. +.2
But by only changing the subroutine this runs across 3 CONCURRENT threads.
perl -Mthreads -Mbignum -le '$_->join foreach map async { while ($i++ < 2) {$j++; $j *= 1.1 for (1..9999)} }, 1..2'Process/threads listing
root@blackjack:/usr/bin# ps -efL | grep perl root 10757 8844 1 1 0 10:32:46 pts/1 0:00 grep pe +rl usr 10755 9335 1 3 0 10:32:44 pts/2 0:00 perl -M +threads -Mbignum -le $_->join foreach map async { while ($i++ < 2) {$ +j++ usr 10755 9335 2 3 1 10:32:44 pts/2 0:02 perl -M +threads -Mbignum -le $_->join foreach map async { while ($i++ < 2) {$ +j++ usr 10755 9335 3 3 1 10:32:44 pts/2 0:02 perl -M +threads -Mbignum -le $_->join foreach map async { while ($i++ < 2) {$ +j++
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl threading problem?
by Athanasius (Archbishop) on Jan 17, 2014 at 10:00 UTC | |
by konnjuta (Acolyte) on Jan 19, 2014 at 23:41 UTC | |
|
Re: Perl threading problem?
by BrowserUk (Patriarch) on Jan 17, 2014 at 13:47 UTC | |
by hdb (Monsignor) on Jan 17, 2014 at 14:08 UTC | |
by BrowserUk (Patriarch) on Jan 17, 2014 at 14:55 UTC | |
by BrowserUk (Patriarch) on Jan 17, 2014 at 14:29 UTC |