in reply to Problem with script using threads

Hi,

This is how you do threads, you separate the main thread modules from the worker thread modules

#!/usr/bin/perl -- use strict; use warnings; use threads stack_size => 4096; use Thread::Queue; Main( @ARGV ); exit( 0 ); sub Main { my $q = Threads::Queue->new; ... } sub Worker { require Text::CSV_XS; require SOAP::Lite; require XML::Twig; require Config::IniFiles; require Tie::File; ... }

Replies are listed 'Best First'.
Re^2: Problem with script using threads
by bsshetty17 (Acolyte) on May 11, 2017 at 08:53 UTC

    Update: It is throwing memory fault when run with more then 1 thread. If thread count = 1 then the script executes properly

      :)

      Where is the minimal code needed to reproduce the error?

        Problem occurs vary rarely.

        Narrowing down the problem is what OP was requesting help with. But that is going to be difficult without a test environment.

Re^2: Problem with script using threads
by bsshetty17 (Acolyte) on May 10, 2017 at 05:20 UTC
    Let me try this and let you know. Thanks
      This did not help resolving my problem. Update: I moved the same script to HP-UX server.I am getting memory fault error. any suggestions? OS:uname -a HP-UX xxxxxxx B.11.31 U ia64 2666145408 unlimited-user license
        Well, can you narrow it down to a line of code? Devel::Trace or strace or something :)