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

Problem when multiple subfunctions invoked via ithreads

Thread Next
From:
Kelvin Philip
Date:
February 12, 2009 23:43
Subject:
Problem when multiple subfunctions invoked via ithreads
Message ID:
7934e17c0902122342o1195d3e7lcaf813f277af373a@mail.gmail.com
Hi,

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);*
*$thr1->join;*
**
*my $thr2 = threads->new(\&func_module2);*
*$thr2->join;*

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

Please suggest a solution for this issue.

Regards,
Kelvin

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About