public synchronized ArrayDeque<ReduceTask> assignReduceTask(int slaveID,
			int taskNum) {
		ArrayDeque<ReduceTask> tasks = new ArrayDeque<ReduceTask>();
		ArrayDeque<ReduceTask> potential = slaveReduceTaskList.get(slaveID);
		if (potential != null && potential.size() > 0) {
			for (int i = 0; i < taskNum; i++) {
				ReduceTask task;
				do {
					task = potential.pollFirst();
					if (task == null)
						break;
				} while (jobAssignedTask.get(task.getJob().getId()).contains(
						task));
				if (task == null) {
					break;
				}
				// update the lists
				tasks.add(task);
				HashSet<Task> t = jobAssignedTask.get(jobID);
				int jobID = task.getJob().getId();
				t.add(task);
				jobAssignedTask.put(jobID, t);
				slaveReduceTaskList.put(slaveID, potential);
			}
		}
		return tasks;
	}