473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

perl 5.8.2/3 - thread started by a thread

Hello everyone,

I'm a perl beginner. I created a piece of code starting a first thread which
in turn creates a second thread. Unfortunately the creation of the second
thread hangs the first one. Is there anybody who knows what's going on ?.
I decided to create fully OO software and I wouldn't like to go back into a
fork-based solution.

I also included my test application (I know there are no joins but it's only
for testing purposes)
--------------- test.pl -----------------------
#!/usr/bin/perl -w
use strict;

use Config;
$Config{useithreads} or die "recompile Perl with threads to run this
program.";

use ThrdTest;
#new object
my $object = ThrdTest->new;
#does sth
$object->start;
#wait for a carrige return
my $svalue = <>;
print "\nFINISHED\n";

------------ ThrdTest.pm ------------
package ThrdTest;
use strict;

use threads;

sub new {
my $class = shift;
my $self = {};
bless $self , $class;
return $self;
}

sub start {
my $self = shift;
threads->new(\&aaa, $self, "1");
threads->new(\&ddd, $self,"2");
}

sub aaa {
my $self = shift;
my $val = shift;
while(1) {
print $val;
}
}

sub ddd{
my $self = shift;
my $val = shift;
threads->new(\&aaa, $self, $val); # THE FIRST THREAD STALLS RIGHT HERE
}

return 1;
--------------------------------

Thank you in advance.

--
pawo
[spadam b za duzo gadam]
Jul 19 '05 #1
0 1269

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
52
by: Olivier Scalbert | last post by:
Hello , What is the python way of doing this : perl -pi -e 's/string1/string2/' file ? Thanks Olivier
7
by: Miguel Manso | last post by:
Hi, list. I'm into a psicological doubt that I would like to share with you (you'll know why later on this mail). I'm a programmer with 5 year of experience into Perl. I'm on that point where...
0
by: DP | last post by:
(2nd post, I think my first may have been to the wrong group - sorry) Hello Perl-ers - I´m hoping I can get some help here, because I'm very lost. Don't know Perl, I'm not a programmer. And...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
10
by: Alex | last post by:
I'm not exactly sure how to use these two languages together. It seems to me that they both totally different things. PERL = databases, heavy processing, server functions. But I can also write...
1
by: incd | last post by:
Hello, I started out learning Perl today, but strict mode is just *weird* and not usefull? Why should I use it? What makes $Username different than the other variables? I was wondering, why I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.