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: ", @_; }
|
|---|