I have piece of code below in which 5 different threads are created and then correspondingly run method is being called , please advise how can i add synchronization in this as i want when one thread is calling run method then no other thread should enter inside run method
public class SSendEmail implements Runnable {
public static void main(String [] args) throws Exception, IOException, Exception{
for(int i=0;i<5;i++) {
new Thread(new SSendMail()).start();
}
}
public void run() {
String smtpHost = "xxx";
String mailSmtpPort = "000";
String mailTo[] = {"sart@wer.com" };
String mailCc[] = {"sart@wer.com" };
xxsendmail(mailTo, mailCc, "sendername",
"testsubject.", "testsubject..", smtpHost , mailSmtpPort);
}
}