in reply to multithread and STDOUT locking

Somewhat easier than using lock() all over your code, is to wrap print in your own sub that does that for you:

use threads; use threads::shared; my $sem :shared; sub tprint { my $tid = threads->tid; lock $sem; print "$tid: ",@_, "\n"; } sub twarn { my $tid = threads->tid; lock $sem; warn "$tid: ", @_; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.