forked from shinezejian/javaStructures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.java
More file actions
45 lines (37 loc) · 1005 Bytes
/
Copy pathProcess.java
File metadata and controls
45 lines (37 loc) · 1005 Bytes
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
40
41
42
43
44
45
package com.zejian.structures.Queue;
/**
* Created by zejian on 2016/12/3.
* Blog : http://blog.csdn.net/javazejian [原文地址,请尊重原创]
* 模拟进程
*/
public class Process implements Comparable<Process> {
private String name;//进程名称
private int priority;//进程优先级默认5,范围1~10
public Process(String name,int priority){
this.name=name;
if(priority>=1&&priority<=10){
this.priority=priority;
}else{
throw new IllegalArgumentException("priority must between 1 and 10");
}
}
public Process(String name){
this(name,5);
}
/**
* 优先级比较
* @param o
* @return
*/
@Override
public int compareTo(Process o) {
return this.priority-o.priority;
}
@Override
public String toString() {
return "Process{" +
"name='" + name + '\'' +
", priority=" + priority +
'}';
}
}