On Wed, 16 Mar 2005 17:26:02 GMT, Severian
<se******@chlamydia-is-not-a-flower.com> wrote:
I have corrected several typos in my response below. Then I must go do
some real work until my brain starts working properly again!
On 16 Mar 2005 07:37:16 -0600,
ka****************@catalytic-dot-com.no-spam.invalid (request) wrote:
Hi
I have written a program which receives mails from server using POP3.
it's downloading sequentially. now i want to use the multithreading
in this regard where i can create threads for each and every
mail...and download those mails simaltaneously.
if u have any idea please help me out.
(I am assuming you are downloading from multiple servers
simultaneously, and not trying to download a bunch of messages from a
single account; I don't believe POP3 even supports the latter)
First, be careful *not* to share resources without synchronization:
two threads shouldn't write to the same file simultaneously, for
example. Mutexes, critical sections and semaphores can be useful for
this, depending on the circumstances.
I would look around on SourceForge, CodeProject, and CodeGuru for
projects that do similar things -- perhaps as servers -- and learn
about synchronization between threads.
Since your application is a client, it can start a thread for each
POP3 server. If the e-mails are being written to separate files, you
only need to coordinate file names between the threads; if appended to
a single mailbox *file*, then the threads will have to wait for each
other to finish writing a message before beginning to write their own.
Another option would be for each receiver thread to write each message
to a temp file. An additional thread would be signaled when a file is
complete and append it to the inbox.
I hope this helps and gives you some ideas.
--
Sev