Writing Multithreaded Applications with the Messaging Access SDK
Table of Contents | Previous | Next | Index

Messaging Access SDK Guide


Appendix A
Writing Multithreaded Applications with the Messaging Access SDK

This appendix provides some important information for developers who want to take advantage of multithreading in their messaging applications.

The C Messaging Access SDK is NOT thread-safe. A multithreaded application must ensure the atomic execution of each function. In addition, it may need to provide a lock on the SDK in order to synchronize state-sensitive sequences of commands within the SMTP, POP3, and IMAP4 modules.

For example, if two threads that are connected to the same SMTP server are used to send mail, a lock is needed to prevent both threads from sending mail at the same time. If the smtp_rcptTo calls of the two threads are interleaved, the email may be sent to the wrong destination.

[Top]

Multithreading in the MIME API

In general, in the MIME API, concurrent access by multiple threads is not applicable. This is because multiple threads should not need to change the same mime_message_t or other MIME objects, for example, mime_multiPart_t, concurrently.

One situation that is applicable in a multithreaded environment is the simultaneous parsing of multiple messages by different threads. To do this, use the parseEntireMessage or the parseEntireMessageInputstream calls, which can be invoked by multiple threads at the same time.

During MIME dynamic parser operations, multiple threads can share the same instance of the mimeParser structure to parse different messages, but the client application must serialize access to the mimeParser instance. Several mimeParser instances can share a single instance of the mimeDataSink_t structure.

[Top]


Table of Contents | Previous | Next | Index

Last Updated: June 3, 1998

Copyright © 1998 Netscape Communications Corporation