develooper Front page | perl.beginners | Postings from February 2009

Problem when multiple subfunctions invoked via ithreads

Thread Next
Kelvin Philip
February 12, 2009 23:43
Problem when multiple subfunctions invoked via ithreads
Message ID:

I am calling two seperate fuctions defined under two different perl modules
via two independent threads. Now, I use the $thr->join; command to wait for
the first thread to complete and then start the second. But it seems that
the two module functions are being executed simultaneously. The interpreter
throws error saying that some variables which are used in the second
function is uninitialised. Actually , those were defined in the first
function. My code looks something like this:

*use threads;*
*use strict;*
*use warnings;*
*use module1;*
*use module2;*
*my $thr1 = threads->new(\&func_module1);*
*my $thr2 = threads->new(\&func_module2);*

Note: The func_module1 & func_module2 are subfunctions defined under moule1
& module2 respectively.

Please suggest a solution for this issue.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About