I have developed an application that sends emails. Initially this application was hanging while sending mail, The idea of sending mail through code> threads , but sending mail with thread also my application is still hanging when email is being sent.
UPDATE
I have updated my code but still have the same problem when using joining () goes.
This is my code (I have shortened the code for ease of understanding in my thread implementation)
was Boolean mailers = false; Send Public Zero (Mail) () {Send Thread Email = New Thread (Send New ("abc@xyz.com"); SendEmail.start (); Confirm Thread = New Thread (New Confirmation Mailers); SendEmail.start (); Try {SendEmail.join (); } Hold (exception e) {} confirmIt.start (); } Send a public class mail mailworld {send string}; Public sendmail (sends string) {this.sentTo = sendTo; } Public Zero Run () {// Mail to send mail is = true; }} Confirm the public class MailSent executes Runnable {Public Zero Run () (if (Mailers) {feedbackText.setText (null); FeedName.setText (Zero); JoptionPan. ShowMesadIdig (empty, "mail sent successfully "," Mail send ", joppenpan. INFORMATION_MESSAGE);}}}
To send mail, the code should be run ()
Send a public nickmail () {Send Thread Email = New Thread (New SendMail ("abc@xyz.com")) sendEmail.start ();} Public Send {Send String} to SendMail Tools; Send Public Mail (Sent String) {this.sendTo = sendTo;} @ Override Public Wide Run () {// Code to send email}}
Comments
Post a Comment