Hi BrowserUK, This is my first try at threads so you are right that my understanding is currently limited.

Inside the method I am trying to call, I am creating a new FosDataCapture Object. During the _init phase of this object it gathers a bunch of data via telnet from the swObject (this is a fibre channel switch). This process can take 60 seconds for switch and I will have over 30 switches when running in production. Without threading, this portion of the code will take too long to run. I think that answers the first two questions.

You stated that threads->create() requires a code reference. According to the threads link you posed it states the following:

--------- $thr = threads->create(FUNCTION, ARGS) This will create a new thread that will begin execution with the specified entry point function, and give it the ARGS list as parameters. It will return the corresponding threads object, or undef if thread creation failed. FUNCTION may either be the name of a function, an anonymous subroutine, or a code ref -------------

With this definition, my first thought my call should be like this:

$thread = threads->create($self->_openFDCObject,$swObject,$switch);

When I called it like this, $swObject and $switch do not get passed into the function. So I tried a few other structures to see what might work since I could find no examples of how to use threads inside an object when calling a function inside the object.

Any further help would be greatly appreciated. Thanks

In reply to Re^2: How do I used a threaded subroutine inside a perl object by adamcpfeiffer
in thread How do I used a threaded subroutine inside a perl object by adamcpfeiffer

Title:
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, details, 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, summary, 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.