ue1
parent
5edbe0efd7
commit
a053915cea
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="eigenes/src"/>
|
||||
<classpathentry kind="src" path="src/pp.01.01-Inheritance_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.01.01-Inheritance/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.01.02-Runnable_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.01.02-Runnable/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.01.03-EndThread_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.01.03-EndThread/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.02.01-MemoryBarrier_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.02.01-MemoryBarrier/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.02.02-ThreadLocal_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.02.02-ThreadLocal/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.02.03-Lock_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.02.03-Lock/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.03.01-SynchPhilosopher_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.03.01-SynchPhilosopher/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.03.02-BoundedQueueWaitNotify_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.03.02-BoundedQueueWaitNotify/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.03.03-BoundedQueueAwaitSignal_solution/src/main/java"/>
|
||||
<classpathentry kind="src" path="src/pp.03.03-BoundedQueueAwaitSignal/src/main/java"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PP-Labs_WS-2024-2025</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -6,7 +6,7 @@ public class Starter {
|
|||
|
||||
public static void main(String... args) {
|
||||
for (var i = 0; i < Starter.WORKERS; i++) {
|
||||
var t = new Thread(new MyWorker(), String.format("Worker-%03d", i));
|
||||
var t = new Thread(new MyWorkerCoop(), String.format("Worker-%03d", i));
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package pp;
|
||||
|
||||
public class StarterInner {
|
||||
|
||||
static int WORKERS = 200;
|
||||
|
||||
public static void main(String... args) {
|
||||
for (var i = 0; i < Starter.WORKERS; i++) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Thread t = Thread.currentThread();
|
||||
while (true) {
|
||||
System.out.println(t.getName() + ": ID => " + t.threadId());
|
||||
}
|
||||
}
|
||||
}, String.format("Worker-%03d", i));
|
||||
|
||||
t.start();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package pp;
|
||||
|
||||
public class StarterLambda {
|
||||
|
||||
static int WORKERS = 200;
|
||||
|
||||
public static void main(String... args) {
|
||||
for (var i = 0; i < WORKERS; i++) {
|
||||
Thread t = new Thread(() -> {
|
||||
// Verwenden von Thread.currentThread() als Lambda-Ausdruck
|
||||
Thread t1 = Thread.currentThread();
|
||||
while (true) {
|
||||
System.out.println(t1.getName() + ": ID => " + t1.threadId());
|
||||
}
|
||||
}, String.format("Worker-%03d", i));
|
||||
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,5 +12,17 @@ public class Runner {
|
|||
e.printStackTrace(System.err);
|
||||
});
|
||||
thread.start();
|
||||
|
||||
Thread s = new Thread( () -> {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
System.out.println("Task wird gestoppt.");
|
||||
task.stopRequest();
|
||||
});
|
||||
s.start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue