SR has asked for the wisdom of the Perl Monks concerning the following question:

Hi I need to use threads in Perl5.8.8, but when i give use threads I encounter the following error

This Perl hasn't been configured and built properly for the threads module to work. (The 'useithreads' configuration option hasn't been used.)

Having threads support requires all of Perl and all of the XS modules in the Perl installation to be rebuilt, it is not just a question of adding the threads module. (In other words, threaded and non-threaded Perls are binary incompatible.)

If you want to the use the threads module, please contact the people who built your Perl.

Can anybody tell me how to proceed with this??

Replies are listed 'Best First'.
Re: Perl5.8.8 Threads
by chromatic (Archbishop) on Feb 06, 2007 at 05:10 UTC

    You either need to build your own Perl, or find a binary package for your operating system with threads support enabled. This is a compile-time setting for Perl.

Re: Perl5.8.8 Threads
by guliver (Friar) on Feb 06, 2007 at 09:40 UTC
    Depending on the OS on which you run perl you can use Active State perl or build your own perl with thread support:
    sh Configure -Dusethreads (see INSTALL in your perl source distribuition).
Re: Perl5.8.8 Threads
by wazzuteke (Hermit) on Feb 06, 2007 at 14:32 UTC
    First, a quick note in the previous comment - The configuration option is -Duseithreads (with an 'i'). Easy mistake and I think the configure script will pick up the miss-key, but nevertheless something to point out.

    Second... assuming you do re-compile a new Perl with the -Duseithreads configuration option:

    Installing a new DBI::DBD under your new libraries will almost always (though may have been fixed in recent versions, sorry if so) throw a warning noting you should not use threads in a production environment. Something along the lines of:
    *** You are using a perl configured with threading enabled. *** You should be aware that using multiple threads is *** not recommended for production environments
    I wouldn't worry so much about this. It's a relatively bold statement in the first place to say this, particularly when the Perl thread tutorial says otherwise.

    In any event, take the warning as you see fit; just wanted to let you know what to expect when installing the new modules.

    ---------
    perl -le '$.=[qw(104 97 124 124 116 97)];*p=sub{[@{$_[0]},(45)x 2]};*d=sub{[(45)x 2,@{$_[0]}]};print map{chr}@{p(d($.))}'
Re: Perl5.8.8 Threads
by Anonymous Monk on Feb 07, 2007 at 00:00 UTC
    I'd go with wazzuteke's comments re prodn.
    I wrote a RADIUS pkt handler for an ISP that runs 24/7 in threads just fine.
    I thought the default Perl build inc threads automatically (at least on Linux).
    FYI, if you are on Linux, I noticed that 2.4 kernel shows each thr as a separate process, whereas 2.6 kernel you only see 1 process in 'top'.

    Cheers
    Chris