@@ -0,0 +1,25 @@ | |||
package Prog3.src.DiningPhilosophers; | |||
public class Fork { | |||
private boolean inUse = false; | |||
private final int id; | |||
public Fork(int id){ | |||
this.id = id; | |||
} | |||
public int getId(){ | |||
} | |||
public boolean take(){ | |||
} | |||
public void put(){ | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
package Prog3.src.DiningPhilosophers; | |||
public class Philosopher implements Runnable{ | |||
protected int id; | |||
protected final Fork left; | |||
protected final Fork right; | |||
public Philosopher(int id, Fork left, Fork right) { | |||
this.id = id; | |||
this.left = left; | |||
this.right = right; | |||
} | |||
@Override | |||
public void run(){ | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package Prog3.src.DiningPhilosophers; | |||
public class Table { | |||
public static void main(String[] args){ | |||
Fork[] forks = { new Fork(0), new Fork(1), new Fork(2), | |||
new Fork(3), new Fork(4)}; | |||
Philosopher[] philosophers = { | |||
new Philosopher(0, forks[0], forks[1]), | |||
new Philosopher(1, forks[1], forks[2]), | |||
new Philosopher(2, forks[2], forks[3]), | |||
new Philosopher(3, forks[3], forks[4]), | |||
new Philosopher(4, forks[4], forks[0]) | |||
}; | |||
for (Philosopher philosopher : philosophers) { | |||
Thread t = new Thread(philosopher); | |||
t.start(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
package Praktikum03.helloworld; | |||
public class ErrorWriter implements IHelloWorldWriter{ | |||
@Override | |||
public void writeHelloWorld(){ | |||
System.err.println("Hello World"); | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
package Praktikum03.helloworld; | |||
public class Executor{ | |||
public static void printHelloWorld(IHelloWorldWriter writer1, IHelloWorldWriter writer2, boolean second){ | |||
} | |||
} |
@@ -0,0 +1,6 @@ | |||
package Praktikum03.helloworld; | |||
public interface IHelloWorldWriter { | |||
void writeHelloWorld(); | |||
} |
@@ -0,0 +1,9 @@ | |||
package Praktikum03.helloworld; | |||
public class OutWriter implements IHelloWorldWriter{ | |||
@Override | |||
public void writeHelloWorld(){ | |||
System.out.println("Hello World"); | |||
} | |||
} |