I'm a bit late to this party. :-)

I'm not too sure about windows, but DBI / DBD::mysql on linux with threads works fine, for certain values of fine:

You can't share handles over multiple thread. You should probably not use a handle that's in scope from the parent thread either. Every thread should have its own database handle(s), so create new connections at the start of a thread if you need them.

You need to compile DBD::mysql with thread support. AFAIK most default builds are done without thread support even on systems that have a threaded perl.

On my (linux) system, that means running mysql_config  --libs_r and passing the output of that to Makefile.PL prior to compilation:

$ mysql_config --libs_r -L/usr/lib/mysql -lmysqlclient_r $ perl Makefile.PL --libs "-L/usr/lib/mysql -lmysqlclient_r"
Note that libmysqlclient_r.so is the threaded version of the libmysqlclient library on linux, libmysqlclient.so is the default, non-threaded version.

PS: starting a new thread in perl is slow. You might not want to do it for each event. Having a pool of threads is probably more efficient.


In reply to Re: Multi-thread database script by Joost
in thread Multi-thread database script by nandn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.