I want to send 1 mail every 5 minutes irrepective of how many times i call sendmail() in 5 minutes ? For eg.
- if i call sendmail at 10 pm .first mail should be sent
- If i call sendmail at 10:03 and 10:04 no mail should be sent.
- If i call sendmail at 10 :06 mail should be sent as difference is
greater than 5 mins
How to achieve it?
public class SendMyEmail {
private boolean sendMail=false;
public void sendmail(String msg) {
if(sendMail) {
System.out.println(" Mail sent " +msg);
}