in reply to Re^2: mutiple threading
in thread mutiple threading
as per the suggestions by perlCrazy, I think a possible thread safe re-write of above code can be
use threads; use DBI; $SQL_1 = "SELECT * FROM x"; $SQL_2 = "SELECT * FROM y"; $SQL_3 = "SELECT * FROM z"; sub start_thread { my ($SQL) = @_; my $dbh = DBI->connect( <your connection string> ); # print('Thread started: ', SQL, "\n"); my $sth = $dbh->prepare($SQL); $sth->execute(); < Add your code here > } my $thr1 = threads->create('start_thread', $SQL_1); my $thr2 = threads->create('start_thread', $SQL_2); my $thr3 = threads->create('start_thread', $SQL_3); $thr1->join(); $thr2->join(); $thr3->join();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: mutiple threading
by BrowserUk (Patriarch) on Aug 09, 2007 at 16:05 UTC | |
by atemon (Chaplain) on Aug 24, 2007 at 05:01 UTC | |
by BrowserUk (Patriarch) on Aug 24, 2007 at 05:31 UTC | |
|
Re^4: mutiple threading
by Anonymous Monk on Sep 03, 2007 at 10:59 UTC | |
by atemon (Chaplain) on Sep 03, 2007 at 12:01 UTC |