Hi Shawn, On Wednesday 07 Apr 2010 16:05:24 Shawn H Corey wrote: > Shlomi Fish wrote: > > I would really recommend against using threads: > > > > * http://perldoc.perl.org/perlthrtut.html > > > > * http://www.perlmonks.org/index.pl?node_id=288022 > > > > They don't work as expected in Perl (though in C/C++, .NET and/or Java, > > they may be an option[Thr]), and cause too many problems. If you are > > keen on doing multi-tasking you should use either fork() and > > multi-processing or something like http://poe.perl.org/ , but often > > multi-tasking is the wrong solution for the problem. > > You can't use fork() in Windows. When you do, it actually uses threads > emulate fork(). This is because of the overhead in registering a new > Windows process with Windows (which is why threads were invented in the > first place).
According to: http://www.cs.clemson.edu/~mark/multithreading.html (first hit for "history multithreading") Threads started in the 1950's - a long time before either Windows or even UNIX . So threads were not invented for Microsoft Windows as a replacement for fork(). It is true that the Win32 API does not have a fork()-like system call (very unfortunately as you ask me) and they used to recommend threads as an incomplete substitute, and that perl 5 uses them on Strawberry Perl / ActivePerl / etc. (not cygwin) to emulate the UNIX fork() . Naturally, on Windows Perl, if one of your fork()ed threads crashes you lose the entire program, which is not the case on Unix or on cygwin. Nevertheless, if you are going to run Perl on UNIX systems exclusively, you shouldn't use threads. And if you're planning to do such multi-tasking on Windows using Perl - please reconsider. > > Many of the complaints of threads have been address. For example they > now do copy-on-write, the same as fork(). That's actually the reason people prefer to use threads over processes in different languages - so they'll share memory. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ The Case for File Swapping - http://shlom.in/file-swap Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/