develooper Front page | perl.ithreads | Postings from May 2010

Re: Help with concurrent threads

Thread Previous
From:
Jerry D. Hedden
Date:
May 6, 2010 06:26
Subject:
Re: Help with concurrent threads
Message ID:
h2o1ff86f511005060625k558320a3vd2b1b9dba6adba25@mail.gmail.com
I tweaked it a bit.  Attached.

On Thu, May 6, 2010 at 06:02, alfonso caponi <alfonso.caponi@gmail.com> wrote:
> Inspired by the pool.pl example, I wrote a simple multi-thread script for
> dns server testing on my LAN. It seems working fine, but I would like your
> opinion on any improvements.
>
> Note: I've commented "#while (! $TERM)" to avoid multiple requests while !
> $TERM :(
>
> Thank you very much at all!
>
> 2010/4/16 Jerry D. Hedden <jdhedden@cpan.org>
>>
>> Get the 'threads' distribution from CPAN and look at the sample
>> scripts in the 'examples' directory.
>>
>> On Fri, Apr 16, 2010 at 11:48, alfonso caponi <alfonso.caponi@gmail.com>
>> wrote:
>> > Hi list,
>> >
>> > I've some doubts with a multi-threads script. My goal is to create a
>> > script
>> > with the same max number of threads running at all times.
>> >
>> > For example: I've an array with 9 elements and 3 threads to process it;
>> > each
>> > thread can process an element using a different time (a thread could end
>> > before another) and I would like 3 threads always running.
>> >
>> > My idea is to take an element from a queue, start threads to reach the
>> > maximum number of active threads allowed and simultaneously start a
>> > separate
>> > (but unique) thread to wait every thread in execution.
>> >
>> > In attachment my "solution". Have you any tips? I would not use other
>> > modules as well threads, threads::shared, thread::queue.
>> >
>> > Thank you very much!
>> > Al
>
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About