use threads::shared; my $sem : shared; sub tprint { lock $sem; print @_; } sub twarn { lock $sem; warn @_; }