📄 myprocess.java
字号:
/* * Process.java * * Created on 2006年3月16日, 下午8:06 * *The Process Class *Including the common view of a process */package os.process;/** * * @author Vernkin */public class MyProcess { /**allocate for process ID**/ private static int ID_COUNT = 0; /**allocate for system id *(A process may have different system id at different time) *Determined by the num enter into ProcessManager*/ private static int SYSTEM_ID_COUNT = 0; private String name; private String status; /**priority 1 ~ 7 as 1 is least and 7 is largest. Defualt 4 **/ private int priority; private int id; private int system_id; private boolean isLoad; private int allocatedMemory; /** Creates a new instance of Process */ public MyProcess(String name){ this(name,4); } public MyProcess(String name,int priority) { this.name = name; //check for priority if(priority < 1) priority = 1; else if(priority > 7) priority = 1; this.priority = priority; id = ID_COUNT++; system_id = 0; System.out.println("Create Process "+name+" "+id); } /**Whether the first param(Process) have right to run first *Principial : first priority,then system_id(system_id smaller = larger) **/ public static boolean firstRun(MyProcess first,MyProcess second){ if(first.priority > second.priority) return true; if(first.priority < second.priority) return false; /**Two process have the same priority**/ if(first.system_id < second.system_id) return true; if(first.system_id > second.system_id) return false; return true; } public void setStatus(String in){ status = in; } public String getStatus(){ return status; } public int getAllocatedMemory(){ return allocatedMemory; } public void setAllocatedMemory(int in){ allocatedMemory = in; } public void setSystemID(){ this.system_id = this.SYSTEM_ID_COUNT++; } public int getSystemIDCount(){ return SYSTEM_ID_COUNT; } public int getSystemID(){ return system_id; } public int getID(){ return id; } public String getName(){ return name; } public boolean getIsLoad(){ return isLoad; } public int getPriority(){ return priority; } public void setPriority(int in){ priority = in; } public void setIsLoad(boolean new_value){ isLoad = new_value; } public String toString(){ return "["+name+" "+id+"]"; } public static void main(String[] args) { // TODO code application logic here /* MyProcess s1 = new MyProcess("s1"); MyProcess s2 = new MyProcess("s2"); MyProcess s3 = new MyProcess("s3", 5); s1.setSystemID(); s2.setSystemID(); System.out.println(MyProcess.firstRun(s1, s2)); System.out.println(MyProcess.firstRun(s1, s3)); */ String s = "01234567"; System.out.println(s.substring(0,4)); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -