The first thing to do is make sure that your version of Perl was compiled with thread support.
The output from perl -V on my system includes the following lines:
C:\pwe>perl -V
Summary of my perl5 (revision 5 version 10 subversion 0) configuration
+:
Platform:
osname=MSWin32, osvers=5.2, archname=MSWin32-x64-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define,
and also:
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_64_BIT_I
+NT
USE_ITHREADS USE_LARGE_FILES USE_PERLIO
USE_SITECUSTOMIZE
Once you are satisfied that your Perl supports threads, you might want to compare your code with this snippet from one of my programs (which happily uses quite a few threads) and see if comparing it with your code might help.
foreach my $seq (0..$number-1)
{
my $doneflag = \$play_done[$seq];
$$doneflag = 0;
$play_list[$seq] = threads->create(\&PlayoutThread,
$doneflag,
$target_list[$seq],
$media_type,
$portnum,
$playouts);
# Mark as already done if thread creation failed
unless ($play_list[$seq])
{
$$doneflag = 2;
$play_errors++;
}
# Count it if thread creation succeeded
else
{
$started++;
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.