Yurttas/PL/OOL/Java/F/07/02/Philosopher.java
Jump to navigation
Jump to search
1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @author : Salih Yurttas.
12 */
13
14
15public class Philosopher implements Runnable {
16
17 private Fork a,
18 b;
19 public int n;
20
21 public Philosopher(final int n,
22 final Fork a,
23 final Fork b) {
24 this.a = a;
25 this.b = b;
26 this.n = n;
27 }
28
29 public void run(){
30 while(true) {
31 a.pickUp();
32 b.pickUp();
33
34 System.out.println("Philosopherosopher " +
35 n +
36 " is eating");
37
38 b.putDown();
39 a.putDown();
40 }
41 }
42
43}