If you are sharing these file handles between threads, then you should be synchronising access to them anyway. Ie. declare a shared variable for use as a mutex, take a lock() on them before printing to them and release it afterward.
Something like this where the logging file is declared before the threads are started?
#!/usr/bin/perl use threads; use threads::shared; my $loglock :shared ; open(LOG, ">/usr/local/lease.log"); sub ilog{ my $text = shift; lock $loglock; print LOG $text; } ## Start defining threads from here on
From your post, this is what I gathered. This should work when multiple threads write to the log file and when one has a lock on the variable, the others cannot write until the lock goes out of scope.
In reply to Re^4: Perl5.8.4 , threads - Killing the "async" kid
by MonkeyMonk
in thread Perl5.8.4 , threads - Killing the "async" kid
by MonkeyMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |