148 |
|
public int compareTo(Delayed other) { |
149 |
|
if (other == this) // compare zero ONLY if same object |
150 |
|
return 0; |
151 |
< |
ScheduledFutureTask<?> x = (ScheduledFutureTask<?>)other; |
152 |
< |
long diff = time - x.time; |
153 |
< |
if (diff < 0) |
154 |
< |
return -1; |
155 |
< |
else if (diff > 0) |
156 |
< |
return 1; |
157 |
< |
else if (sequenceNumber < x.sequenceNumber) |
158 |
< |
return -1; |
159 |
< |
else |
160 |
< |
return 1; |
151 |
> |
if (other instanceof ScheduledFutureTask) { |
152 |
> |
ScheduledFutureTask<?> x = (ScheduledFutureTask<?>)other; |
153 |
> |
long diff = time - x.time; |
154 |
> |
if (diff < 0) |
155 |
> |
return -1; |
156 |
> |
else if (diff > 0) |
157 |
> |
return 1; |
158 |
> |
else if (sequenceNumber < x.sequenceNumber) |
159 |
> |
return -1; |
160 |
> |
else |
161 |
> |
return 1; |
162 |
> |
} |
163 |
> |
long d = (getDelay(TimeUnit.NANOSECONDS) - |
164 |
> |
other.getDelay(TimeUnit.NANOSECONDS)); |
165 |
> |
return (d == 0)? 0 : ((d < 0)? -1 : 1); |
166 |
|
} |
167 |
|
|
168 |
|
/** |