?? simproc.java
字號:
import java.util.Random ;class SimProc extends Thread { private Scheduler mySched ; private int count ; private char nm ; //private int count ; public SimProc(Scheduler sch, String name,int /*int*/ i) { super(name) ; mySched = sch ; count = i ; start() ; } public /*float */int getCount() { return count ; } private void addToReadyQueue() { mySched.addProcess(this) ; } private void removeFromReadyQueue() { mySched.removeProcess(this) ; mySched.endSlice(this) ; // want something else to run! } public void run() { RoundScheduler rou = new RoundScheduler() ; //FifoScheduler rou=new FifoScheduler(); addToReadyQueue() ; while(count > 0) { mySched.endSlice(this) ; //int k = Math.abs(myrand.nextInt()) ; //int ans = collatz(k) ; //if (ans > 0) count-- ; //輪轉(zhuǎn)開始 int time1=rou.quant; if(count<rou.quant) time1=count; if(count>0.001) System.out.println("This is " + getName() + " - Time is " +time1 ) ; count-=rou.quant;//輪轉(zhuǎn)結束 /*System.out.println("This is " + getName() + " completed! " ) ; break;*/ } removeFromReadyQueue() ; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -