Reputation: 253
I am stuck on one problem: I want to send a useraccountname and password via mail, but with a 1 minute interval between. That is, the useraccountname should go be sent first via mail, and after a 1 minute interval should be sent too.
How do I implement the logic for this 1 minute interval in Java?
Upvotes: 0
Views: 312
Reputation: 27356
You can use a ScheduledExecutorService
. This allows you to queue up tasks with given time intervals.
Example
You create a Runnable
..
Runnable runnable = new Runnable() {
public void run() { System.out.println("Do something!"); }
}
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate() // I won't tell you how to do this!
Upvotes: 2
Reputation: 1044
You can tell the thread to wait if it's not multithread:
Thread.sleep(60000);
Upvotes: 0