week05/leetcode_1226/soluton_momo262_v0.java
// call the run() method of any runnable to execute its code
call the run() method of any runnable to execute its code
call the run () method of any runnable to execute its code
public void wantsToEat(int philosopher,
                           Runnable pickLeftFork,
                           Runnable pickRightFork,
                           Runnable eat,
                           Runnable putLeftFork,
                           Runnable putRightFork) throws InterruptedException {
        lockList.get(philosopher%5).lock();
        lockList.get((philosopher+1)%5).lock();
        pickLeftFork.run();
        pickRightFork.run();
        eat.run();
        putLeftFork.run();
        putRightFork.run();
        lockList.get(philosopher%5).unlock();
        lockList.get((philosopher+1)%5).unlock();
    }
public void wantsToEat ( int philosopher , Runnable pickLeftFork , Runnable pickRightFork , Runnable eat , Runnable putLeftFork , Runnable putRightFork ) throws InterruptedException { lockList . get ( philosopher % 5 ) . lock ( ) ; lockList . get ( ( philosopher + 1 ) % 5 ) . lock ( ) ; pickLeftFork . run ( ) ; pickRightFork . run ( ) ; eat . run ( ) ; putLeftFork . run ( ) ; putRightFork . run ( ) ; lockList . get ( philosopher % 5 ) . unlock ( ) ; lockList . get ( ( philosopher + 1 ) % 5 ) . unlock ( ) ; }
call the run() method of any runnable to execute its code
call the run () method of any runnable to execute its code