test.java

来自「用JAVA实现的」· Java 代码 · 共 106 行

JAVA
106
字号
package cpusimu;

public class TEST {
	public static void main(String args[])
	{
		CPU c=new CPU(2,3,7);
		Thread t1=new Thread(1,1,0);
		Seg a1=new Seg(1,15,400);
		t1.add(a1);
		Seg a2=new Seg(2,18,0);
		t1.add(a2);
		Thread t2=new Thread(1,2,12);
		Seg b1=new Seg(1,4,150);
		t2.add(b1);
		Seg b2=new Seg(2,30,0);
		t2.add(b2);
		c.insert(t1);
		c.insert(t2);
		while(c.ready.size()>0)
			c.attemper();
		for(int i=0;i<c.ready.size();i++)
		{
			System.out.println(c.ready.get(i).getFirstarrivetime());
		}
		for(int i=0;i<c.finish.size();i++)
		{
			System.out.println(c.finish.get(i).getFirstarrivetime());
			System.out.println(c.finish.get(i).getFinishtime());
			System.out.println();
		}
		System.out.println(c.utilization());
		System.out.println();
		c.print(true, true);
	}
}
/*2 3 7


1 4 

1 0 6

1 15 400

2 18 200

3 15 100

4 15 400

5 25 100

6 240

2 12 4

1 4 150

2 30 50

3 90 75

4 15 

3 27 4

1 4 400

2 810 30

3 376 45

4 652

4 28 7

1 37 100

2 37 100

3 37 100

4 37 100

5 37 100

6 37 100

7 37 


2 2

1 0 3 

1 150 2

2 4 5

3 22

2 1 1

1 50 */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?