my $semSTDOUT : shared; sub tprint{ lock $semSTDOUT; print @_; } tprint "$tid: Some text";