Follow these steps to implement the example:
- Create a class named Task and specify that it implements the Runnable interface:
public class Task implements Runnable {
- Declare a private String attribute called name that will store the name of the task:
private final String name;
- Implement the constructor of the class that initializes the attribute:
public Task(String name) { this.name=name; }
- Implement the run() method. Write a message to the console with the actual date to verify that the task is executed within the specified period:
@Override public void run() { System.out.printf("%s: Executed at: %s\n",name,new Date()); }
- Implement the main class of the example by creating a class named Main and adding ...