yeet
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package Klausur_ueb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ThreadTraining {
|
||||
public static void main(String[] args) {
|
||||
@@ -38,7 +42,7 @@ class MyThread2 extends Thread {
|
||||
wait(100);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +61,45 @@ class CoolNumber {
|
||||
return tmp;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class ExecuteTask {
|
||||
public static void main(String[] arg) {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(3);
|
||||
int sumWartezeit = 1000;
|
||||
java.util.Random zufall = new java.util.Random();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String name = "" + i;
|
||||
int wartezeit = zufall.nextInt(1000);
|
||||
sumWartezeit = sumWartezeit + wartezeit;
|
||||
Runnable task = new Task(name, wartezeit);
|
||||
System.out.println("Task " + name + " mit Wartezeit " + wartezeit + " wird an den Threadpool uebergeben.");
|
||||
executor.execute(task);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(sumWartezeit);
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(sumWartezeit, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Task implements Runnable {
|
||||
private String name;
|
||||
private int wartezeit;
|
||||
|
||||
public Task(String name, int wartezeit) {
|
||||
this.name = name;
|
||||
this.wartezeit = wartezeit;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
System.out.println("Task " + name + " beginnt um " + System.currentTimeMillis() + ".");
|
||||
try {
|
||||
Thread.sleep(wartezeit);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
System.out.println("Task " + name + " ist fertig um " + System.currentTimeMillis() + " .");
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/Klausur_ueb/MyThread.class
Normal file
BIN
out/production/Anwendungsentwicklung/Klausur_ueb/MyThread.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/Klausur_ueb/MyThread2.class
Normal file
BIN
out/production/Anwendungsentwicklung/Klausur_ueb/MyThread2.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/Klausur_ueb/Square.class
Normal file
BIN
out/production/Anwendungsentwicklung/Klausur_ueb/Square.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
31
out/production/Anwendungsentwicklung/P11/date.c
Normal file
31
out/production/Anwendungsentwicklung/P11/date.c
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by jordi on 1/8/24.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Definition der Date-Struktur
|
||||
struct Date {
|
||||
int day;
|
||||
int month;
|
||||
int year;
|
||||
};
|
||||
|
||||
// Funktion zur Ausgabe des Datums im Format dd.mm.yyyy
|
||||
void printDate(struct Date *date) {
|
||||
printf("%02d.%02d.%04d\n", date->day, date->month, date->year);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Erstellen eines Date-Objekts und Zuweisen von Werten
|
||||
struct Date myDate;
|
||||
myDate.day = 8;
|
||||
myDate.month = 1;
|
||||
myDate.year = 2024;
|
||||
|
||||
// Aufrufen der Funktion zum Ausgeben des Datums
|
||||
printf("Das Datum ist: ");
|
||||
printDate(&myDate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
9
out/production/Anwendungsentwicklung/P11/test2.c
Normal file
9
out/production/Anwendungsentwicklung/P11/test2.c
Normal file
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Created by jordi on 1/8/24.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
printf("hallo");
|
||||
}
|
||||
Reference in New Issue
Block a user