📄 philopher.java
字号:
public class Philopher extends Thread
{
int i;
public Philopher(int i){
this.i=i;}
public void run(){
if (i%2==0){
Main.fork[i].P();
Main.fork[(i+1)%5].P();
System.out.println("Philopher"+i+"is eating");
Main.fork[i].V();
Main.fork[(i+1)%5].V();}
else{
Main.fork[(i+1)%5].P();
Main.fork[i].P();
System.out.println("Philopher"+i+"is eating");
Main.fork[(i+1)%5].V();
Main.fork[i].V();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -