+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
df69975
master
1class Philosopher implements Runnable { 2int id =0 ; 3Resource r =null ; 4public Philosopher (int initId ,Resource initr ) { 5id =initId ; 6r =initr ; 7new Thread (this ).start (); 8 } 9public void run () { 10while (true ) { 11try { 12System .out .println ("Phil " +id +" thinking" ); 13Thread .sleep (30 ); 14System .out .println ("Phil " +id +" hungry" ); 15r .acquire (id ); 16System .out .println ("Phil " +id +" eating" ); 17Thread .sleep (40 ); 18r .release (id ); 19 }catch (InterruptedException e ) { 20return ; 21 } 22 } 23 } 24}