Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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:

  • Not all modules are thread safe. And a large number of modules (possibly most) will not include anything in their documentation to indicate if it is thread safe or not.
  • Portability: If a Perl installation was not compiled to support threads, then your code won't work in that Perl installation.
  • Support: You might have a hard time finding help. And in many forums, you might receive harsh responses about using threads.

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).

In reply to Re: Can we write multi-threaded scripts ? by dasgar
in thread Can we write multi-threaded scripts ? by toughy

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (8)
    As of 2021-03-07 21:30 GMT
    Find Nodes?
      Voting Booth?
      My favorite kind of desktop background is:

      Results (122 votes). Check out past polls.