Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm starting this in a new node, even though it seems closely related to one I wrote last week: Why do my threads sometimes die silenty?. I am trying to start a pool of threads inside a BEGIN{} block, as per the recommendation on Things you need to know before programming Perl ithreads. My reasons for doing this is that my program loads some modules which are not thread safe, so I want to make sure that the threads in the pool are started before those modules are actually instantiated. Below is a piece of code which tries to do that.
However, when I run it as is, all I get is the final "done", and the file "hello.dat" doesn't even get created. However, if I comment out the line:
and its corresponding closing brace, I get the expected output
and the "hello.dat" file does get created and contains the two "hello" messages. Can somebody explain to me why the threads don't actually run when they are inside a BEGIN {} block, but do when they aren't? ThxIn reply to Can't start threads inside a BEGIN{} block by alain_desilets
|
|