From 2e7bf121667bb1d4a05ca63f9692d27d06b6692d Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Thu, 3 Mar 2022 13:48:29 +0100 Subject: [PATCH] Methode run() in Printer.java korrigiert. --- code/Printer/src/main/java/ch/zhaw/prog2/printer/Printer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/Printer/src/main/java/ch/zhaw/prog2/printer/Printer.java b/code/Printer/src/main/java/ch/zhaw/prog2/printer/Printer.java index f14b654..9b1088f 100644 --- a/code/Printer/src/main/java/ch/zhaw/prog2/printer/Printer.java +++ b/code/Printer/src/main/java/ch/zhaw/prog2/printer/Printer.java @@ -15,6 +15,7 @@ public class Printer { private static class PrinterThread extends Thread { char symbol; int sleepTime; + Thread current_thread = this; public PrinterThread(String name, char symbol, int sleepTime) { super(name); @@ -24,7 +25,7 @@ public class Printer { @Override public void run() { - if(Thread.currentThread().getName().equals("main")){ + if(Thread.currentThread() != current_thread){ return; } System.out.println(getName() + " run started...");