Browse Source

Änderungen 05.12.2023 um 14:36

master
leonmcfly 1 year ago
parent
commit
6f46678393

+ 25
- 0
src/DiningPhilosophers/Fork.java View File

@@ -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(){

}


}

+ 18
- 0
src/DiningPhilosophers/Philosopher.java View File

@@ -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(){

}
}

+ 22
- 0
src/DiningPhilosophers/Table.java View File

@@ -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();
}
}
}

+ 9
- 0
src/Praktikum03/helloworld/ErrorWriter.java View File

@@ -0,0 +1,9 @@
package Praktikum03.helloworld;

public class ErrorWriter implements IHelloWorldWriter{

@Override
public void writeHelloWorld(){
System.err.println("Hello World");
}
}

+ 7
- 0
src/Praktikum03/helloworld/Executor.java View File

@@ -0,0 +1,7 @@
package Praktikum03.helloworld;

public class Executor{
public static void printHelloWorld(IHelloWorldWriter writer1, IHelloWorldWriter writer2, boolean second){

}
}

+ 6
- 0
src/Praktikum03/helloworld/IHelloWorldWriter.java View File

@@ -0,0 +1,6 @@
package Praktikum03.helloworld;

public interface IHelloWorldWriter {

void writeHelloWorld();
}

+ 9
- 0
src/Praktikum03/helloworld/OutWriter.java View File

@@ -0,0 +1,9 @@
package Praktikum03.helloworld;

public class OutWriter implements IHelloWorldWriter{

@Override
public void writeHelloWorld(){
System.out.println("Hello World");
}
}

Loading…
Cancel
Save