Thanks Shlomi.
Your statement is a great guide to perl threads to me.
I'm checking the AnyEvent module which looks wonderful.

Thanks again.


Mon, 7 Feb 2011 12:30:32 +0200 письмо от Shlomi Fish <shlo...@iglu.org.il>:

> 
> Well, let me quote the perlbot ( on Freenode's #perl ) factoid:
> 
> [quote]
> 
> <perlbot>       Before you start implementing code using Perl's threads, 
> please remember that Perl's threads are not like other threads. Please see 
> http://perldoc.perl.org/perlthrtut.html to learn more; specifically the "What 
> kind of threads are perl threads?" section. Also see: 
> http://www.perlmonks.org/index.pl?node_id=288022
> 
> [/quote]
> 
> Read these two resources and be enlightened. Threads do not work too well in 
> any of the P-languages, and I was told that threads in Python with its 
> notorious Great-Interpreter-Lock (GIL) suck - not "as bad as Perl" but still 
> pretty badly. I haven't tried threads in Lisp yet.
> 
> Threads work pretty well in C, though they are extremely tricky to get right 
> for non-trivial programs, and they should be pretty OK in .NET too (and again 
> - quite tricky). Java and C++ may support threads nicely, but from what I 
> heard and know developing in them is painful and error-prone in itself. See 
> for example:
> 
> http://lbrandy.com/blog/2010/03/never-trust-a-programmer-who-says-he-knows-c/
> 
> ("-c" there is "C++").
> 
> Some people say threads work very well in languages such as Erlang (where 
> threads are "green threads" and are also used as a kind of cheap abstraction, 
> and one can often spawn thousands of them on a machine with much fewer cores 
> or processors), Haskell and other purely functional languages, but I don't 
> know about that.
> 
> In any case, if you want to do multi-tasking in Perl, you should something 
> like either forking and multi-processing or the recommendations here such as 
> POE, Net::Async, IO::Lambda, Reflex, AnyEvent, etc:
> 
> http://perl-begin.org/uses/multitasking/
> 
> Some people think that threads should be avoided even in languages where they 
> have acceptable performance. See for example:
> 
> http://www.faqs.org/docs/artu/ch07s03.html#id2923889
> 
> Furthermore, in regards to parallelism, in the Algorithm Design Manual 
> ( http://www.algorist.com/ ) says something that it is a good idea to split 
> the task in such ways that processing every task is self-contained and 
> requires as little interaction from the other tasks (IIRC).
> 
> Personally, I've done some simple multi-threading projects, but can imagine 
> that more complex ones will be much more error-prone and hard to get right.
> 


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to