Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF, 078274121, info0a ip, should prodicers of software_based services be held liable or not liable for economic injuries

Links

XODOX
Impressum

#1: new Thread cannot work

Posted on 2008-04-18 03:32:49 by happytown277

Hi, buddies.
The code below can't work on my WindowsXP with SP2:

===============
#!/usr/bin/perl

use Thread qw/async yield/;

my $var = 0;

sub abump {
lock $var;
if ($var == 0) {
yield;
$var++;
}
}

my $t1 = new Thread \&abump;
my $t2 = new Thread \&abump;

for my $t ($t1, $t2) {
$t->join;
}

print "var is $var\n";
===============
It show me this information below after I run the code:
"Undefined subroutine &threads::new called at E:\test\learnperl
\thread.pl line 15."

And line 15 is:
my $t1 = new Thread \&abump;

I test the code under Linux, but the result is ways:
"var is 0";

So, what is wrong?

BTW: the code is one example of "Programming Perl" (third edition).
And it is in chapter "Threads".

===============
Thanks anyway in advance.

Best wishes

happytown277


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message

#2: Re: new Thread cannot work

Posted on 2008-04-18 12:08:23 by happytown277

Sorry for these line:
"It show me this information below after I run the code: "
" I test the code under Linux, but the result is ways:"

They should be:
"It shows me this information below after I run the code: "
"I test the code under Linux, but the result is aways: "


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message

#3: Re: new Thread cannot work

Posted on 2008-04-18 12:39:17 by chas.owens

On Thu, Apr 17, 2008 at 9:32 PM, <happytown277@googlemail.com> wrote:
> Hi, buddies.
> The code below can't work on my WindowsXP with SP2:
snip
> It show me this information below after I run the code:
> "Undefined subroutine &threads::new called at E:\test\learnperl
> \thread.pl line 15."
>
> And line 15 is:
> my $t1 = new Thread \&abump;
>
> I test the code under Linux, but the result is ways:
> "var is 0";
>
> So, what is wrong?
snip

Most likely the version of Perl you are using was not compiled to use
threads. Type

perl -V

on the commandline and look for

Compile-time options

and tell use what it says after that.

--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message