/media/sda-magnetic/david/Extern-Magnetic-2022-06-29/Extern01/Dokumente-2021-05-8/disk10-ab-2020-01-10/02-debian-pc2-work/informatik/java-new/2020-12-17/Warum.java


import java.io.IOException;

public class Warum {
    public static void main(String[] argv) {
        Test t = new Test();
        t.start();
        t.dotry();
        t.stop();
    }
}

class Test extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println("Hallo, ich komme.");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                // Sollte nicht geschehen, zur Sicherheit Ausgabemeldung
                System.out.println("Beim Schlafen unterbrochen");
            }
        }
    }

    // Zum Beenden Enter-Taste druecken
    void dotry() {
        try {
            System.in.read(); // Blockiert bis Zeile eingegeben
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("Ich gehe. Auf Wiedersehen!");
    }
    public void stop () {
       if (Thread != null)
           Thread = null;
    }

}