Follow these steps to implement the example:
- First, implement the tasks that will be executed by the server. Create a class named Task that implements the Runnable interface:
public class Task implements Runnable {
- Declare a Date attribute named initDate to store the creation date of the task and a String attribute called name to store the name of the task:
private final Date initDate; private final String name;
- Implement the constructor of the class that initializes both the attributes:
public Task(String name){ initDate=new Date(); this.name=name; }
- Implement the run() method:
@Override public void run() {
- First, write the initDate attribute and the actual date, which is the starting date of the task: ...