in reply to Re: Why use threads over processes, or why use processes over threads?
in thread Why use threads over processes, or why use processes over threads?

Just for kicks, read the code required to create a new thread in Perl. Any operating system that can't launch a new process more quickly than Perl can launch a new thread is severely broken.

Is that a consequence of implementation, or is it a real design flaw in Perl's threading code? I really don't know enough about threading implementation to know, but I suspect this is a problem that is fixable in future versions.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

  • Comment on Re: Re: Why use threads over processes, or why use processes over threads?
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Why use threads over processes, or why use processes over threads?
by chromatic (Archbishop) on Nov 11, 2003 at 18:15 UTC

    That's a consequence of implementation. Creating a new thread means cloning a Perl interpreter. That requires a lot of work. That's where something like Thread::Pool is handy; you still pay the price for launching threads, but you do it at startup.