develooper Front page | perl.ithreads | Postings from March 2008

RE: Simple Thread question

Thread Previous
From:
Wong, Danny H.
Date:
March 31, 2008 17:52
Subject:
RE: Simple Thread question
Message ID:
D331130DD3DA194B96EF57DA3415F50A0216DF9A@SAUSCUPEXCH01.corp.sa.net
Hi Chris,
	Thanks for your replay. I realized that  after sending the
email... Looking at to much code will do this to you...

-----Original Message-----
From: Christopher Fowler [mailto:cfowler@outpostsentinel.com] 
Sent: Monday, March 31, 2008 4:20 PM
To: Wong, Danny H.
Cc: perl-ithreads@perl.org
Subject: Re: Simple Thread question

I think your problem is the join().  Do not join the thread directly
after creating it.

Create both threads then join().


On Mon, 2008-03-31 at 16:01 -0700, Wong, Danny H. wrote:
> Hi Thread Guru's,
>     I'm just reading up on Perl threads for the first time from 
> http://perldoc.perl.org/perlthrtut.html
> <http://perldoc.perl.org/perlthrtut.html> .  
> 
> After reading the document and trying out a test script myself. Can 
> someone tell me what I'm doing something wrong? It's a simple copy 
> function that copies a big file ~50MB, but I was hoping that the 
> copying happens in parallel but its not. Any ideas what I need to do? 
> I'll like to try the boss-worker and pipeline method. any information
would great.
> thanks for your help.
> 
> Here is my code?
> 
> use threads;
> 
> use File::NCopy <file::NCopy>  qw (copy);
> 
> my $FILE='c:\tmp\ADK61292p-Explorer8010hd-ATSC-SA-pKey.zip';
> 
> my $DIR1='C:\tmp\test1';
> 
> my $DIR2='C:\tmp\test2';
> 
> my $THREAD_1 = threads->create(\&COPYTOTESTAREA, ${FILE}, ${DIR1}); 
> print "Thread 1" . $THREAD_1->join() ." is done\n";
> 
>  
> 
> my $THREAD_2 = threads->create(\&COPYTOTESTAREA, ${FILE}, ${DIR2}); 
> print "Thread 2" . $THREAD_2->join() ." is done\n";
> 
>  
> 
> sub COPYTOTESTAREA
> 
> {
> 
> my ($SOURCE, $DESTINATION) = @_;
> 
> copy("${SOURCE}", "${DESTINATION}");
> 
> return "I'm done";
> 
> }
> 
> 
> 
> 
> 
>      - - - - - Appended by Scientific Atlanta, a Cisco company - - - -
-         
> This e-mail and any attachments may contain information which is 
> confidential, proprietary, privileged or otherwise protected by law. 
> The information is solely intended for the named addressee (or a 
> person responsible for delivering it to the addressee). If you are not

> the intended recipient of this message, you are not authorized to 
> read, print, retain, copy or disseminate this message or any part of 
> it. If you have received this e-mail in error, please notify the
sender immediately by return e-mail and delete it from your computer.


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