e][i]=allocation[choose][i]+req[i];
need[choose][i]=need[choose][i]-req[i];
}
int[] work1=new int[3];
for (int i = 0; i < work1.length; i++) {
work1[i]=available[i];
}
boolean[] finish1=new boolean[process];
for (int i = 0; i < process; i++) {
finish1[i]=false;
}
int[] array1=new int[process];
int num1=1;
int count11=1;
while(num1
for (int i = 0; i < process; i++) {
for (int j = 0; j < 3; j++) {
if(f
inish1[i]==false){
if(need[i][0]<=work1[0]&;&;need[i][1]<=work1[1]&;&;need[i][2]<=work1[2]){
for (int j2 = 0; j2 < resource; j2++) {
work1[j2]=work1[j2]+allocation[i][j2];
}
finish1[i]=true;
array1[count11-1]=i;
count11++;
}
}
}
}num1++;
}
int count2=0;
for (int i = 0; i < array1.length; i++) {
if(finish1[i]==true){
count2++;
}
}
if(count2==process){
System.out.println("存在一个安全序列:");
for (int i = 0; i < array1.length; i++) {
System.out.print("P"+array1[i]+" ");
}
System.out.println();
/*
* 打印资源分配表
* */
System.out.println("最新时刻的资源分配表");
System.out.println("进程 max\t\tallocation\t need\t\tavailable");
System.out.print("P0 ");
for (int i = 0; i System.out.print(max[0][i]+" ");<