in reply to databases and multithreading

Your code isn't complete, and it looks like you define $dbh before you spawn your threads. Threads get a copy of the parent when spawned, so your my $dbh in the thread may not be working. Try to isolate all the db stuff into the thread code block. Or try to undef $dbh first thing in your thread code block, then redeine it with my. Otherwise, play it safe and fork your code.

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: databases and multithreading
by hjf (Initiate) on Dec 01, 2008 at 18:56 UTC
    there is a $dbh (just to test, I called it $dbg) in a main thread and another $dbh for each thread, both $dbg and $dbh are declared "my". (so 1 main + 3 threads = 4 independent DB connections). Each threads calls the method "hitMe" every time they end processing the data from the DB, and I need to process about 70.000 rows in the DB, but I can only process 3 at a time, so that's why I thought of threading it.