Follow these steps to implement the example:
- Create a class named Event and specify that it implements the Comparable interface parameterized by the Event class:
public class Event implements Comparable<Event> {
- Declare a private int attribute named thread to store the number of threads that have created the event:
private final int thread;
- Declare a private int attribute named priority to store the priority of the event:
private final int priority;
- Implement the constructor of the class to initialize its attributes:
public Event(int thread, int priority){ this.thread=thread; this.priority=priority; }
- Implement the getThread() method to return the value of the thread attribute:
public int getThread() ...