Skip to content

Commit 07da5b0

Browse files
committed
Fix
1 parent 86cdbcd commit 07da5b0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/com/thealgorithms/scheduling/AgingScheduling.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ public AgingScheduling() {
3333
taskQueue = new LinkedList<>();
3434
}
3535

36+
/**
37+
* Adds a task to the scheduler with a given priority.
38+
*
39+
* @param name name of the task
40+
* @param priority priority of the task
41+
*/
3642
public void addTask(String name, int priority) {
3743
taskQueue.offer(new Task(name, priority));
3844
}
3945

46+
/**
47+
* Schedules the next task based on the priority and wait time.
48+
* The priority of a task increases with the time it spends waiting.
49+
*
50+
* @return name of the next task to be executed
51+
*/
4052
public String scheduleNext() {
4153
if (taskQueue.isEmpty()) {
4254
return null;

0 commit comments

Comments
 (0)