Thread-safe?

2006-09-13
2013-04-08
  • Just a quick question, is jwSMTP thread-safe? Can I use it to send mails from different threads, i.e. one mail per thread?

    TIA.

     
    • John Wiggins
      John Wiggins
      2006-09-17

      Thread safe is a difficult question.
      Yes the mailer class is thread safe in that if you keep each mailer object you create contained in a single thread.
      If mailer objects are passed within threads it will be up to you to make sure you deal with concurrency issues. This is normal for any code in a multi threaded program.
      e.g. if you change the mail message in one thread while you are sending the mail in another thread who knows the result! You will have to make sure you don't change the object if you are sending it's mail maybe by using a critical section or whatever your OS names its concurrency primitives.