http://dev.mysql.com/doc/mysql/en/c-thread-functions.html
Have a look at this. Also if you are compiling it using the pthread library, you can directly use the functions provided by ptherad library. And you need not to do the forking also. This sample code might give you an understanding.. Int hit_DB { Create a connection here and use for whatever purpose. } for (user = 0; user < concurrent_users; user++) { pthread_attr_init(&attr[user]); pthread_attr_setschedpolicy(&attr[user], SCHED_RR); } for (user = 0; user < concurrent_users; user++) { pthread_create(&helper[user], NULL, hit_DB, (void *)user); } for (user = 0; user < concurrent_users; user++) { pthread_join(helper[user], NULL); } Hope this helps... sujay -----Original Message----- From: Lefteris Tsintjelis [mailto:[EMAIL PROTECTED] Sent: Saturday, September 24, 2005 5:37 PM To: Sujay Koduri Cc: mysql@lists.mysql.com Subject: Re: Multithread handling of Connect/Close Sujay Koduri wrote: > I think mysql does not allow multiple threads to act on the same connection. > You have to create a connection pool and pick one for each thread Either that or keep handling them on a per thread basis but do I have to also do mysql_server_init/end on a per child then, or just once in the parent proc? while loop childid { fork(); ... mysql_server_init(...); mysql_real_connect(...) ...handle thread... mysql_close(...) mysql_server_end(); ... } exit(0); or should it be something like: mysql_server_init(...); while loop childid { fork(); ... mysql_real_connect(...) ...handle thread... mysql_close(...) ... } mysql_server_end(); exit(0); Thnx, Lefteris -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]