根据c语言程序修改成java,我对c语言的指针不精通。哪位同仁有这样的程序,帮我看看怎么修改,谢谢了。共同学习。
//以下是c程序模拟进程运行void proc(struct PCB *running)
 显示当前进程ID
 当前进程共执行几个时间片
 利用delay()函数依次显示剩余时间片
 若时间片用完,则将该进程转为低优先级就绪状态
 若时间片未用完,利用rand()函数产生随机数。若该数>=100,则进程继续运行剩余的时间片;否则,调用proc_wait()函数将进程阻塞。进程调度函数 int proc_switch()
 若高优先级就绪队列非空,则执行队首进程,分配2个时间片;
 若高优先级队列为空,则执行低优先级队列队首进程,分配5个时间片;
 若高、低优先级队列均为空,则执行进程唤醒int proc_wakeup()
进程调度成功,返回1;否则返回0;进程等待函数 int proc_wait()
 将当前运行进程置高优先级,等待时间为20,插入等待队列尾部。进程唤醒函数proc_wakeup()
若等待队列为空,返回0;否则,返回1
 等待队列中每个进程的等待时间减1
 从等待队列中摘除等待时间为0的进程,插入到高优先级就绪队列的末尾,等待调度主函数
创建7个新进程,初始化进程基本信息,置低优先级,等待时间为0;等待队列和高优先级队列为空;
 模拟进程调度过程(循环嵌套:for语句,case语句)#include"stdio.h"
#include"stdlib.h"
#include "string.h"
#define WAIT 1
#define RUN 2
#define FINISH 3
typedef struct pcb
{
      int num;
      struct pcb *next;
      int priority;
      int timeneed;
      int state;
}pcb;/*用此结构体来模拟一个进程*/
struct pcb *head;
struct pcb *run;
pcb *jccreat(int n)/*此函数用于创建进程队列*/
{
      int i=1;
      pcb *head,*p,*q;
      randomize();/*随机函数的初始化*/
      head=(pcb *)malloc(sizeof(pcb));/*创建一个空表头*/
      p=head;
      for(i=1;i<=n;i++)/*用循环来创建指定个结点*/
      {
          q=(pcb *)malloc(sizeof(pcb));
          p->next=q;
          q->num=i;
          q->next=NULL;
          q->priority=random(10);/*随机产生优先级*/
          q->timeneed=random(10);/*随机产生运行时间*/
          q->state=WAIT;
          p=q;
      }
      return head;/*返回表头指针*/
}
pcb *getmaxpriority(struct pcb *head)/*此函数用来挑选一个优先级最大的进程来执行*/
{
      struct pcb *p,*q;
      int max;
      p=head->next;
      max=p->priority;/*初始max为队首结点的优先级*/
      q=p;
      while(p)
      {
          if(p->priority>max)/*逐一比较,选出优先级最大的结点*/
          {max=p->priority;
          q=p;}
          p=p->next;
      }
      return q;
}
void delect(struct pcb *head,struct pcb *run)/*此函数用来将运行完的进程删除出进程队列*/
{
      struct pcb *q=head;
      while(q->next)/*扫描进程队列,找到执行完了的进程*/
      {
          if(q->next->num==run->num)/*判断是不是已完成的进程*/
            {
              if(run->next!=NULL)
              q->next=run->next;
              else q->next=NULL;
              free(run);/*释放申请的空间*/
              return;
          }
      q=q->next;
      }
}
void proc_switch()/*此函数是用来控制各个进程的执行和调度*/
{
      struct pcb *p;
      run=head->next;/*初始让第一个进程运行*/
      run->state=RUN;
      while(run)
      {
          if(run->timeneed>0)/*如果当前run指针指向的进程所需时间不为零,状态为运行状态,就让这个进程运行*/
          if(run->state==RUN)
              {printf("pcb%d is running.\n",run->num);
              printf("Waiting list:");/*显示整个等待队列*/
              p=head->next;
                  while(p)
                  {
                  if(p!=run)
                  printf("pcb%d ",p->num);
                  p=p->next;
                  }
              printf("\n");
              delay(10000000);/*模拟进程运行*/
              run->timeneed--;/*进程需要时间减一*/
              run->priority=run->priority-3;/*进程优先级减三*/
          }
          if(run->timeneed!=0)
          {
              if(run->priority<=head->next->priority)/*如果当前运行完的进程的优先级低于队首进程的优先级*/
                  {run->state=WAIT;
                  run=getmaxpriority(head);/*则从进程队列中挑选一个优先级最大的进程来运行*/
                  run->state=RUN;}
                  }
                  else
                  { printf("pcb%d is finished.\n",run->num);
                  delect(head,run);/*删除该结点*/
                      if(head->next!=NULL)/*判断进程队列是不是为空*/
                      {run=head->next;
                      run->state=RUN;}
                      else
                      {printf("All progresses are done.\n");
              return;}
          }
      }
}main()
{
int n;
int flag=1;
printf("Enter the number of the progresses:");
scanf("%d",&n);/*输入要创建的进程的数量*/
head=jccreat(n);/*创建进程队列,将链表的表头赋给head指针*/
run=head->next;/*run指针指向正在运行的进程的pcb*/
while(run)
{
printf("num: %d ,priority: %d ,timenees: %d \n",run->num,run->priority,run->timeneed);
run=run->next;
} /*将刚创建的进程队列打印出来*/
while(flag)/*由flag的值判断是否继续执行proc_switch()函数*/
{
if(head->next)/*判断进程是否完成*/
proc_switch();
else flag=0;
}
getch();
}