A
andros976
Good evening to all .
I'm designing an application that has the task of sending the email automatically taking the recipients from a db.
To send email I created a special class that receives the string with the recipient's address and sends mail.
The instruction to send the message:
Transport.send (msg ) ;
I noticed that this statement takes a bit of seconds before releasing
flow and therefore are unable to use the other functions of the application . I thought , therefore, to use a technology where each object of the class that sends the email implements Runnable and then i use it like a thread.
I noticed , however, that there are problems because sometimes 20 over 50 emails fail and the instruction that give me the error is
Transport.send (msg ) ;
java.net.SocketException : Connection closed by remote host
and seems to be the fact that the thread dies too fast after the statement
Transport.send (msg ) ;
So I inserted a Thread.sleep ( 10000 ) ;
but sometimes I goes equally mistaken, then I tried to employ
t.join ();
but it blocks the flow (basically waiting for the thread to end it all before giving way to another )
What can I do ?
If you need I can write a few lines of code to make you understand how I'm implementing the functionality described
I look forward ideas
thanks
I'm designing an application that has the task of sending the email automatically taking the recipients from a db.
To send email I created a special class that receives the string with the recipient's address and sends mail.
The instruction to send the message:
Transport.send (msg ) ;
I noticed that this statement takes a bit of seconds before releasing
flow and therefore are unable to use the other functions of the application . I thought , therefore, to use a technology where each object of the class that sends the email implements Runnable and then i use it like a thread.
I noticed , however, that there are problems because sometimes 20 over 50 emails fail and the instruction that give me the error is
Transport.send (msg ) ;
java.net.SocketException : Connection closed by remote host
and seems to be the fact that the thread dies too fast after the statement
Transport.send (msg ) ;
So I inserted a Thread.sleep ( 10000 ) ;
but sometimes I goes equally mistaken, then I tried to employ
t.join ();
but it blocks the flow (basically waiting for the thread to end it all before giving way to another )
What can I do ?
If you need I can write a few lines of code to make you understand how I'm implementing the functionality described
I look forward ideas
thanks