class MemoryQueue {

    public List<ExecutorTask> pullBeforeTime(long maxTime) {
        List<ExecutorTask> polledTasks = new ArrayList<ExecutorTask>();
        ExecutorTask task;
        while ((task = queue.peek()) != null) {
            if (task.getCreateTime() <= maxTime) {
                polledTasks.add(task);
                queue.poll();
            } else {
                break;
            }
        }
        return polledTasks;
    }

}