in reply to Getting a script to do 2 process simultaneously.

Hi, blackadder - love that name, and yes, I'm a Rowan Atkinson fan, but I did not care much for his recent movie "Johnny English" - anyway - that is completely OT.

Back in the real world, It seems that you have re-invented the "diruse" program that comes with the Win2k resource kit.

To test if it is worth converting to multi-tasking, you could run multiple copies of your program, or multiple copies of "diruse", and see if it takes less total time than running serially.

Here is a small program to get you started on multi-threading.

This works on perl 5.8, and uses the Threads module.
use strict; use threads; my @MyThread; my $threadcount = 15; for (0..($threadcount-1)){ $MyThread[$_]=threads->new(\&s,$_,10+$_); }; if ($ARGV[0] eq 'a'){ foreach (@MyThread){ print qq(Return check via thread array from ) . $_->join() . qq(\n +); } }else{ foreach (threads->list()){ print qq(Return check via threads list from ) . $_->join() . qq(\n +); } } ####################### sub s{ my $a=shift; sleep($threadcount-$a); print qq(In sub s param=$a\n); return shift() }

Replies are listed 'Best First'.
Re: Re: Getting a script to do 2 process simultaneously.
by blackadder (Hermit) on Aug 06, 2003 at 16:03 UTC
    Thanks for your help pal,...Rowan Atkinson cannot do wrong,..but I agree with you I didn't think much of his "Johnny English" charactor...but Anyway. Cheers.