Daniel Rychlik wrote:
Good morning,

I am having troubles with threads within my PERL service which was built
to monitor a queue for jobs to do.  The issue I am running into is, I
have an unknown number of jobs to do but can only do 6 at one time.  The
reason that I can only do 6 at one time is because I only have 6
resources available to me for each job.
I looked into using threads to do the jobs asynchronously, as a file
comes into a queue; a loop monitors this queue and then creates a new
thread to carry out that job.

And therein lies the biggest source of your problem.
Tho you haven't provided any code (and I'm disinclined to view
any anyway), I'd strongly advise
you adjust your architecture to create a thread pool at
startup, and use (e.g.) Thread::Queue
to post work to threads as needed; if you need a more
duplex messaging solution, I'll offer Thread::Queue::Duplex.

Constantly creating and destroying threads - regardless the
OS or language, tho esp. for Perl ithreads - is almost *always*
a bad idea, both from a performance and reliability standpoint.

Dean Arnold
Presicient Corp.



Reply via email to