For Programmers: Free Programming Magazines  


Home > Archive > ithreads > June 2006 > question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author question
Collins, Ellen \

2006-06-24, 8:38 am

I am running perl.5.8.7.
My script is attached. It does not run asynchronously. The commands
execute one at a time.
Does this work on windows? I am using windows 2000.
Any help is much appreciated since I have spent much time on this
problem.
THANKS!
<<test2.pl>>
________________________________________
___
> Ellen Seebeck
> Vice President
> Merrill Lynch- Mortgage Research
> World Financial Center, N.Y.
> (212)449-1690- work
> (732)681-7125- home
>
>

--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------

Daniel Rychlik

2006-06-24, 8:38 am

Try using this method and see if it will work;





________________________________

From: Collins, Ellen (RSCH) [mailto:ellen_seebeck@ml.com]
Sent: Tuesday, June 20, 2006 9:06 AM
To: perl-ithreads@perl.org
Subject: question



I am running perl.5.8.7.
My script is attached. It does not run asynchronously. The commands
execute one at a time.
Does this work on windows? I am using windows 2000.
Any help is much appreciated since I have spent much time on this
problem.
THANKS!
<<test2.pl>>

________________________________________
___
Ellen Seebeck
Vice President
Merrill Lynch- Mortgage Research
World Financial Center, N.Y.
(212)449-1690- work
(732)681-7125- home



________________________________

If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy,
retain or redistribute it. Click here <http://www.ml.com/email_terms/>
for important additional terms relating to this e-mail.
http://www.ml.com/email_terms/

________________________________


Daniel Rychlik

2006-06-24, 8:38 am

Sorry about not pasting the code in; but try this and see if this will =
work for you.

use Config;
use threads;

# Build an array of VBS Scripts here...
# This is not tested and may not work, but you get the idea.
my @vbsScripts =3D ("open_test.vbs 1", "open_test.vbs 2");

$Config{useithreads} or die "Recompile Perl with threads to run this =
program\n";

if ( $Config{useithreads} ) {
printf("THREADED\n");
} else {
printf("NOT threaded\n");
}

# Loop through the VBS Scripts, spawn a new thread, detach that thread =
and=20
# begin code execution at sub1

foreach my $vbsScript (@vbsScripts) {

$thread =3D threads->create(&sub1,$vbsScript);
=09
# Detach each thread
$thread ->detach();=20

}


exit(0);

###### SUBROUTINES #########
sub sub1 {
my ($vbsScript) =3D @_;
=09
printf("Processing $vbsScript\n");
=09
system("cscript $vbsScript");
}


________________________________________

From: Collins, Ellen (RSCH) [mailto:ellen_seebeck@ml.com]=20
Sent: Tuesday, June 20, 2006 9:06 AM
To: perl-ithreads@perl.org
Subject: question

I am running perl.5.8.7.=20
My script is attached. It does not run asynchronously. The commands =
execute one at a time.=20
Does this work on windows? I am using windows 2000.=20
Any help is much appreciated since I have spent much time on this =
problem.=20
THANKS!=20
<<test2.pl>>=20
________________________________________
___=20
Ellen Seebeck=20
Vice President=20
Merrill Lynch- Mortgage Research=20
World Financial Center, N.Y.=20
(212)449-1690- work=20
(732)681-7125- home=20

________________________________________

If you are not an intended recipient of this e-mail, please notify the =
sender, delete it and do not read, act upon, print, disclose, copy, =
retain or redistribute it. Click here for important additional terms =
relating to this e-mail.=A0=A0=A0=A0 http://www.ml.com/email_terms/
________________________________________

Mike Pomraning

2006-06-24, 8:38 am

On Tue, 20 Jun 2006, Collins, Ellen \(RSCH\) wrote:

> I am running perl.5.8.7.
> My script is attached. It does not run asynchronously. The commands
> execute one at a time.
> Does this work on windows? I am using windows 2000.
> Any help is much appreciated since I have spent much time on this
> problem.
> THANKS!
> <<test2.pl>>


....

|| $thr1=threads->new(&sub1);
|| $thr2=threads->new(&sub2);

You are calling sub1 and sub2, rather than passing the CODE refs themselves
as entry points for your threads. I believe you mean to say:

$thr1=threads->new(\&sub1);
$thr2=threads->new(\&sub2);

|| # clean up the threads
|| $thr1->detach;
|| $thr2->detach;
||
|| exit(0);

Note, unless you synchronize with your spawned threads, your program will
probably complain that "A thread exited while %d other threads were still
running" when you exit here.

Regards,
Mike
--
cat: .signature: Level 2 halted

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com