ChunLi has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know of where I may locate some good, solid examples of the perl multithreading, or forking mechanisms? I am working on a server which uses an application API to insert records into the database. The problem is that a single process can take days. Is there a way to create multiple child processes with a common parent and pass each of the children a few parms to represent a task?

Replies are listed 'Best First'.
Re: Multithread / Fork Perl Examples.
by jepri (Parson) on Dec 12, 2001 at 09:30 UTC
    This is overkill for what you want, but the discussion has a link to one of Merlyns webtechniques columns which sounds like exactly what you want.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: Multithread / Fork Perl Examples.
by perrin (Chancellor) on Dec 12, 2001 at 09:08 UTC
    See my answer to a similar question from earlier today here. Try MLDBM::Sync for data sharing.
Re: Multithread / Fork Perl Examples.
by sparkyichi (Deacon) on Dec 12, 2001 at 22:21 UTC
    Here is a project I did a while back.
    use Win32::Process; Start_Process(); $Process1->Wait(INFINITE); $Process2->Wait(INFINITE); sub Start_Process{ Win32::Process::Create($Process1, "c:\\close\\pfchk.exe", "pfchk", 0, DETACHED_PROCESS, "c:\\close") || die "Could not Execute Pacific Time Zone M +iss: $!\n"; } Win32::Process::Create($Process2, "c:\\close\\mfchk.exe", "mfchk", 0, DETACHED_PROCESS, "c:\\close") || die "Could not Execute Mountain Time Zone +Miss: $!\n"; } }
    Sorry the code is a little rough, but the Sub kicks of two processes. Then it waits for the first one to finish and then the second. Check out the man page for the Win32::Process module. I hope this was of some help.BR>
    Sparky</FONT