|
From: Shane B. <ast...@te...> - 2003-06-17 19:01:04
|
Hello,
I am new to this list, but I am a long time C/C++ programmer. I =
have recently stepped into some new territory, with regards to threaded =
applications. I have had too success with general interest mailing =
lists, so I hope this will work out too.
I am writing an application wherein over 100,000 records must be =
written between a few tables in a MySQL database. Originally, the =
transactions were direct to the database. The delay on the process was =
too intense... I have opted for a solution which involves only a =
momemtary relay while the process writes a dump file, which will be then =
imported into the database after. To do so, I wanted to use a thread. =
I am aware of fork() and how it works, but I am looking for more =
specific information.
Once the file is created, I will fork a thread, it will verify the =
file exists, then open a connection to the database, dump the file all =
at once, while not preventing processing of the original parent thread. =
My question is how to determine when a child thread has finished? If I =
fork the thread, and get a 0 return, the thread is running, how do I =
know when it is done? More precisely, I want to make sure that while the =
thread is running, the other thread isn't shutdown until the child =
thread is finished. Worst case scenario, it crashes while both threads =
are running, but the original dump file being imported will still remain =
to reimport the database.
When forking a separate thread, do you need to create something =
similar to a message pump to sit in a loop and process messages back =
from the thread? If so, that would require the existing process be run =
as a thread after it's started.
I am sort of confused on how to deal with this issue regarding =
thread-safe programming. I would appreciate any advice, or specific =
reference material that would be informative.
Thank you,
-Shane |