T
tzhong98-101
I am trying to do some threading with perl, and my simple script just
refuses to work. Basically I created a new thread (T1), and then
attempted to create another one (T2) from within T1, which failed
silently. Could anyone tell me why that is?
======== The sample code ========
#!C:/perl/bin/perl.exe
use strict;
use IO::Socket;
use Thread;
use Config;
$Config{useithreads} or die "Recompile Perl with threads to run this
program.";
sub foo2 {
sleep(5);
print "foo2";
print "T2 is done";
}
sub foo1 {
sleep(2);
print "foo1";
my $t2 = new Thread \&foo2;
print "T2 is launched";
}
$\ = "\n";
my $t1 = new Thread \&foo1;
print "T1 is launched";
===== End of sample code ====
The Output:
T1 is launched
foo1
Apparently thread T2 is not even started. What's wrong?
Thanks,
Tim
refuses to work. Basically I created a new thread (T1), and then
attempted to create another one (T2) from within T1, which failed
silently. Could anyone tell me why that is?
======== The sample code ========
#!C:/perl/bin/perl.exe
use strict;
use IO::Socket;
use Thread;
use Config;
$Config{useithreads} or die "Recompile Perl with threads to run this
program.";
sub foo2 {
sleep(5);
print "foo2";
print "T2 is done";
}
sub foo1 {
sleep(2);
print "foo1";
my $t2 = new Thread \&foo2;
print "T2 is launched";
}
$\ = "\n";
my $t1 = new Thread \&foo1;
print "T1 is launched";
===== End of sample code ====
The Output:
T1 is launched
foo1
Apparently thread T2 is not even started. What's wrong?
Thanks,
Tim