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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.