@Override
	public String getNextTask() {
		if (this.initialized == false) {
			throw new IllegalStateException("Scheudlers must be initialized before they can be used.");
		} else if (this.scheduleable == false) {
			throw new IllegalStateException("Task set is not scheduleable.");
		}
		refreshTasks();
		String nextTask = null;
		PeriodicTask pt = periodicTasks.peek();
		if (pt != null) {
			if (pt.getName().equals("SERVER")) {
				nextTask = this.aperiodicTasks.getTaskAtTime(time);
				if (nextTask == null) { /* If there is no aperiodic task to be run, the next periodic task will be run for one time unit. */
					periodicTasks.remove(); /* Must remove the periodic task for the aperiodic server from the priority queue so that we can view the next periodic task to be run. */
					PeriodicTask pt2 = periodicTasks.peek();
					if (pt2 != null) {
						nextTask = pt2.getName();
						updateTask(pt2);
					}
					periodicTasks.add(pt); /* Add the periodic task for the aperiodic server back into the priority queue so that it can be chosen at a later time if an aperiodic task arrives. */
				} else {
					updateTask(pt);
				}
			} else {
				nextTask = pt.getName();
				updateTask(pt);
			}
		}
	
		this.time += 1;
		return (nextTask != null) ? nextTask : "";
	}