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

Re: Re: Multi-Threading in Perl

by edebill (Scribe)
on Dec 26, 2001 at 07:17 UTC ( [id://134340] : note . print w/replies, xml ) Need Help??

in reply to Re: Multi-Threading in Perl
in thread Multi-Threading in Perl

Why is there a need for some 'threading' mechanism in Perl whereas it already has the 'fork' call?

It's hard to share data structures across a fork().

Yes, you can always get the job done using shared files, signals, pipes and such. But for some things it's just a lot more clean to pthread_mutex_lock(), change a variable, and pthread_mutex_unlock(). And select() loops are just obnoxious compared to having a separate thread or process to handle each incoming network connection (as long as you're not expecting super high performance with lots of clients)

Perl's threading works nicely - but it doesn't port to every platform perl does. This has caused me to rewrite at least one app which was originally started in perl using C. Good thing I "planned to throw one away".