soumyapanda has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Multi threading
by BrowserUk (Patriarch) on Aug 03, 2011 at 14:49 UTC

    What error message do you get if you call your thread procedure as a simple function?

    Ie. Instead of:

    my $thr = threads->new( \&worker, ... );

    Do, (temporarily)

    worker( ... );

    Threaded programmers rule 1: When you've sorted out the bugs in your code when running it single threaded, it is an awful lot easier to get it to run multi-threaded.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Multi threading
by moritz (Cardinal) on Aug 03, 2011 at 13:51 UTC
Re: Multi threading
by Utilitarian (Vicar) on Aug 03, 2011 at 13:50 UTC
    It's where you fail to check a return value on line 32 obviously
    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: Multi threading
by locked_user sundialsvc4 (Abbot) on Aug 03, 2011 at 15:30 UTC

    This is, actually, sensible advice.   First, get the program working correctly in a single thread.   Then, get the multithreading logic to work (i.e. threads are launched and terminated correctly), perhaps using dummy logic within those threads.   Only then do you try to put the two pieces together.   (And when you do so, start with “only one thread,” which makes it almost-the-same as the first problem that you’ve already dealt with and solved.)

    When dealing with complex problems, especially ones that have a timing-sensitive element as all threaded programs do, you must reduce the overall problem into a set of smaller ones that you can address individually.   Or, as one of my colleagues put it, “always cross the stream one rock at a time, and try to keep your boots dry as you do it.”

      I thought the advice was "Don't cross the streams!"

      Same idea, however: keep everything independent as long as possible.

Re: Multi threading
by Anonymous Monk on Aug 03, 2011 at 13:52 UTC