http://www.perlmonks.org?node_id=1225280


in reply to Can we write multi-threaded scripts ?

Personally, I hate the "discouraged" label being applied to threads - especially considering the official definition of "discouraged" in the perldocs. The wording of that definition leaves a distinct impression that threads are just a step or two away from being removed from Perl, which becomes a heavy handed scare tactic.

When I first started looking at doing things in parallel, I looked at forks and threads. For some reason, I couldn't get my head wrapped around how to use forks, but I had no trouble with understanding threads. So I started using threads. Some time later, I found documentation (fork in perlport and perlfork) that indicated that Perl will emulate fork using threads in Windows. Since I happen to mainly work in Windows, that means ultimately I will be using threads no matter what I choose between threads or fork.

In my opinion, using threads in Perl code can be ok. However, you do need to keep some things in mind as you do so. This isn't an exhaustive list, but some items that I can think of are:

Personally, I'm not going to try to persuade anyone to use or not to use threads in their Perl code. Instead, I would say try to educate yourself so that you can make an informed decision about your choice to use or not to use threads. In my case, I initially made an uninformed decision and later learned enough information to be able to make an informed decision to continue using threads (at least for now).

  • Comment on Re: Can we write multi-threaded scripts ?