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++
In reply to Perl threading problem? by konnjuta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |