in reply to multithread and STDOUT locking
I really want to look for a good way to lock the stdout,
Not at all. You don't need to lock STDOUT, whatever that means. What you really really want is mutual exclusion. That can be done by obtaining a lock, but it can be a lock on anything, as long as all the parties lock the same thing.
Since you're using threads, you can use a shared variable.
my $stdout_mutex :shared; { lock($stdout_mutex); print ...; }
Then again, if you're using threads, why are you using STDOUT at all. Why not use something like Thread::Queue instead?
|
|---|