From 408769e24d2621706a35b6bd77bc40dfbb801ce0 Mon Sep 17 00:00:00 2001
From: stedS <sven.steddin@reutlingen-university.de>
Date: Mon, 6 Jan 2020 21:52:50 +0100
Subject: [PATCH] Erweiterung Beispielprogramme VL04-09

---
 VL04_09/MultitaskReqExample/.classpath        |  6 +++
 VL04_09/MultitaskReqExample/.project          | 17 +++++++
 .../.settings/org.eclipse.jdt.core.prefs      | 11 +++++
 .../src/inf3/MultiTaskReqExample.java         | 45 +++++++++++++++++++
 4 files changed, 79 insertions(+)
 create mode 100644 VL04_09/MultitaskReqExample/.classpath
 create mode 100644 VL04_09/MultitaskReqExample/.project
 create mode 100644 VL04_09/MultitaskReqExample/.settings/org.eclipse.jdt.core.prefs
 create mode 100644 VL04_09/MultitaskReqExample/src/inf3/MultiTaskReqExample.java

diff --git a/VL04_09/MultitaskReqExample/.classpath b/VL04_09/MultitaskReqExample/.classpath
new file mode 100644
index 0000000..63b7e89
--- /dev/null
+++ b/VL04_09/MultitaskReqExample/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/VL04_09/MultitaskReqExample/.project b/VL04_09/MultitaskReqExample/.project
new file mode 100644
index 0000000..fcaa57c
--- /dev/null
+++ b/VL04_09/MultitaskReqExample/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>MultitaskReqExample</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>
diff --git a/VL04_09/MultitaskReqExample/.settings/org.eclipse.jdt.core.prefs b/VL04_09/MultitaskReqExample/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..bb35fa0
--- /dev/null
+++ b/VL04_09/MultitaskReqExample/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/VL04_09/MultitaskReqExample/src/inf3/MultiTaskReqExample.java b/VL04_09/MultitaskReqExample/src/inf3/MultiTaskReqExample.java
new file mode 100644
index 0000000..f2e7a26
--- /dev/null
+++ b/VL04_09/MultitaskReqExample/src/inf3/MultiTaskReqExample.java
@@ -0,0 +1,45 @@
+/** MultitaskReqExample.java
+* 
+* Das Programm stellt einen Versuch dar, ein Konsolenprogramm 2 Aufgaben erledigen
+* zu lassen:
+* a) Fortlaufende Ausgabe der Zeit
+* b) Einlesen eines Zeichens, um das Progammende einzuleiten
+* Es wird auf das Zeichen 0 getestet.
+* Leider erledigt das Programm die Aufgabe nicht wie erwartet:
+* Der Read-Befehl blockiert die Schleife, solange kein Zeichen eingegeben wird.
+* Wie lässt sich das Problem beheben?
+*
+* @author Steddin
+* @version 1.00, 2017-01-12
+*/
+package inf3;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+//import static java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+public class MultiTaskReqExample {
+
+	public static void main(String[] args) {
+		
+		InputStreamReader isr = new InputStreamReader(System.in);
+		while (true) {
+			LocalDateTime timePoint = LocalDateTime.now();
+			String timeString = timePoint.truncatedTo(ChronoUnit.SECONDS).format(DateTimeFormatter.ISO_LOCAL_TIME);
+			System.out.print(timeString);
+			char[] cbuf = new char[3];
+			try {
+				isr.read(cbuf);
+				if (cbuf[0] == '0') {
+					break;
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		System.out.println("Programmende");		
+	}
+}
+
+
-- 
GitLab