Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Multi threading

by cdarke (Prior)
on Apr 06, 2009 at 07:55 UTC ( [id://755654] : note . print w/replies, xml ) Need Help??


in reply to Re^2: Multi threading
in thread Multi threading

As Corion said, you create processes with fork(), not threads. If you have multiple writers to a file then there are several solutions - none of them particularly good!
The simplest is to lock the whole file for each writer - but that defeats the object of having multiple writers.
Another is to allocate specific regions (by byte offset) of the file for each thread/process ensuring that these do not overlap. That avoids locking, but requires some planning and management. Use seek to position each thread/process.
If you turn off buffering for the write you will reduce the overlap, but probably not get rid of it altogether.

Replies are listed 'Best First'.
Re^4: Multi threading
by sandy1028 (Sexton) on Apr 06, 2009 at 09:15 UTC
    Can you please tell me how to lock it. Any tutorial or any example related to this