hjf has asked for the wisdom of the Perl Monks concerning the following question:
But it complains that the connection is already being used by thread N (program's main thread) and that db handlers aren't shared. So how can I feed my threads with data from the db in a synchronized manner? Thanks$dbh=... $sth->execute() $sth->bind_columns(...) t1= new Thread \&processor; t2= new Thread \&processor; t1->join(); t2->join(); #ends here# sub hitMe { # :locked? $sth->fetch(); return (columns...); } sub processor { my $dbconn.... my $dbh... while(@data=hitme()) { process stuff; $dbh->something(); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: databases and multithreading
by Fletch (Bishop) on Dec 01, 2008 at 19:34 UTC | |
|
Re: databases and multithreading
by zentara (Cardinal) on Dec 01, 2008 at 18:41 UTC | |
by hjf (Initiate) on Dec 01, 2008 at 18:56 UTC | |
|
Re: databases and multithreading
by Joost (Canon) on Dec 01, 2008 at 22:29 UTC | |
|
Re: databases and multithreading
by Anonymous Monk on Dec 02, 2008 at 11:35 UTC | |
by hjf (Initiate) on Dec 02, 2008 at 12:08 UTC |