This is a very basic representation of how your threading model might look:
use 5.16.2; use threads; use Thread::Queue; my @serverList = qw(one two three four five six); my $serverQueue = Thread::Queue->new( @serverList ); $serverQueue->end; my @threads = map { threads->new( \&worker ) } 1..4; $_->join for @threads; say 'Back to main - Finished!'; sub worker { my $tid = threads->tid; while ( my $server = $serverQueue->dequeue_nb ) { say "I'm thread ID $tid and I'm processing server $server to c +opy a whole bunch of files"; sleep 1; } say "Thread ID $tid finished"; }
In reply to Re^3: Queuing in multithread context
by SimonPratt
in thread Queuing in multithread context
by Hardin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |