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?

And then there's the real argument: safety. Forked processes default to not sharing; threads default to sharing everything. With the former, you have to explicitly share what you desire to be shared while with the latter you have to explicitly make thread local copies of sensitive data.

Perhaps you haven't actually looked at the docs for threads? To wit:

It is very important to note that variables are not shared between threads, all variables are per default thread local. To use shared variables one must use threads::shared.
  • Comment on Re: Re: Why use threads over processes, or why use processes over threads?

Replies are listed 'Best First'.
Re^3: Why use threads over processes, or why use processes over threads?
by Aristotle (Chancellor) on Nov 11, 2003 at 19:11 UTC
    Actually, I know (and knew) about this and thought about it while writing my reply; but I was talking about threads in the general sense, not the threading model found in Perl 5.6+. For all intents and purposes, "threads" in 5.6+ are userland forks. So in Perl I have the choice between kernel forks and userland forks (whose performance and memory use is as is to be expected - just what kernel forks used to be once upon a time) - now guess which ones I'll prefer. At least on sane OSes where kernel forks are available..

    Makeshifts last the longest.