zoukankan      html  css  js  c++  java
  • FIFO 调度器中比较器的具体实现

    1. class JobQueueJobInProgressListener extends JobInProgressListener ,其中JobQueueJobInProgressListener有个静态内部类JobSchedulingInfo
    2. int compare(Object o1, Object o2) 返回一个基本类型的整型
      如果要按照升序排序,
      则o1 小于o2,返回-1(负数),相等返回0,01大于02返回1(正数)
      如果要按照降序排序
       则o1 小于o2,返回1(正数),相等返回0,01大于02返回-1(负数)
    3. //按照jobschedulinginfo信息升序排列
    4. static final Comparator<JobSchedulingInfo> FIFO_JOB_QUEUE_COMPARATOR
          = new Comparator<JobSchedulingInfo>() {
          public int compare(JobSchedulingInfo o1, JobSchedulingInfo o2) {
            int res = o1.getPriority().compareTo(o2.getPriority());
            if (res == 0) {
              if (o1.getStartTime() < o2.getStartTime()) {
                res = -1;
              } else {
                res = (o1.getStartTime() == o2.getStartTime() ? 0 : 1);
              }
            }
            if (res == 0) {
              res = o1.getJobID().compareTo(o2.getJobID());
            }
            return res;
          }
        };
  • 相关阅读:
    sass---基本语法
    sass--概述与基本操作手册
    DOS命令--基本常用命令
    PHP中的几种输出格式
    PHP操控数据库
    MySQL数据库
    前端小知识
    TextView控件的介绍及实现跑马灯的效果
    枚举类型和 struct类型
    Button的四种监听方式
  • 原文地址:https://www.cnblogs.com/cxtblogs/p/5031032.html
Copyright © 2011-2022 走看看