下面列出了java.util.concurrent.Delayed#hashCode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public int compareTo(Delayed that) {
long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
if (thisDelay < thatDelay) {
return -1;
}
if (thisDelay > thatDelay) {
return 1;
}
// 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
if (this.equals(that)) {
return 0;
} else {
return this.hashCode() - that.hashCode();
}
}
@Override
public int compareTo(Delayed that) {
long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
if (thisDelay < thatDelay) {
return -1;
}
if (thisDelay > thatDelay) {
return 1;
}
// 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
if (this.equals(that)) {
return 0;
} else {
return this.hashCode() - that.hashCode();
}
}
@Override
public int compareTo(Delayed that) {
long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
if (thisDelay < thatDelay) {
return -1;
}
if (thisDelay > thatDelay) {
return 1;
}
// 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
if (this.equals(that)) {
return 0;
} else {
return this.hashCode() - that.hashCode();
}
}
@Override
public int compareTo(Delayed that) {
long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
if (thisDelay < thatDelay) {
return -1;
}
if (thisDelay > thatDelay) {
return 1;
}
// 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
if (this.equals(that)) {
return 0;
} else {
return this.hashCode() - that.hashCode();
}
}
@Override
public int compareTo(Delayed that) {
long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
if (thisDelay < thatDelay) {
return -1;
}
if (thisDelay > thatDelay) {
return 1;
}
// 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
if (this.equals(that)) {
return 0;
} else {
return this.hashCode() - that.hashCode();
}
}
public int compareTo(Delayed other) {
if (other == null || this.hashCode() > other.hashCode())
return 1;
if (this.hashCode() == other.hashCode())
return 0;
return -1;
}