in reply to Perl threading problem?

Hello konnjuta,

You don’t say how you are determining the number of threads. But here is my guess as to what you are seeing:

The second script compiles quickly and creates 2 new threads, which together with the parent thread make 3 in all.

The first script sees 2**859433-1 and tries to calculate that during the compile phase, and so — since the calculation takes a long time — no threads are actually spawned, because the script never actually runs. The “one thread” you observe is really the perl interpreter compiling the script prior to running it.

Run both scripts with perl -c ... to verify.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Perl threading problem?
by konnjuta (Acolyte) on Jan 19, 2014 at 23:41 UTC
    Thank you Athanasius. I forgot to mention the keyword CONCURRENT threads. Your explanation regarding compile phase make alot of sense.