forked from OnlyTerminator/GeekThread
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeekThread.java
More file actions
39 lines (31 loc) · 1.02 KB
/
Copy pathGeekThread.java
File metadata and controls
39 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.geek.thread.task;
import com.geek.thread.ThreadPriority;
/**
* Created by aotuman
* the thread that can set priority
*/
public abstract class GeekThread extends Thread implements GeekPriorityComparable{
private ThreadPriority mPriority = ThreadPriority.LOW;
public GeekThread(ThreadPriority priority) {
this.mPriority = priority;
}
@Override
public void setGeekPriority(ThreadPriority priority) {
this.mPriority = priority;
}
@Override
public ThreadPriority getGeekPriority() {
return mPriority;
}
@Override
public int compareTo(GeekPriorityComparable another) {
if (null == another) {
return 1;
}
return getGeekPriority().getPriorityValue() - another.getGeekPriority().getPriorityValue();
}
@Override
public boolean equals(Object obj) {
return null != obj && obj instanceof GeekPriorityComparable && ((GeekPriorityComparable) obj).getGeekPriority() == getGeekPriority() && super.equals(obj);
}
}