From accae07b295ec15081c51a842abcb03921ce2a30 Mon Sep 17 00:00:00 2001 From: Konloch Date: Sun, 13 Feb 2022 15:35:24 -0600 Subject: [PATCH] Code Cleanup --- .../club/bytecodeviewer/util/MiscUtils.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java index 1f614398..f152b1a9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java @@ -9,8 +9,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -293,10 +291,26 @@ public class MiscUtils } } - public static Thread startNewThread(String threadName, Runnable threadRunnable) + /** + * START's a new thread (Creates a new thread and runs that thread runnable on it) + */ + public static Thread createNewThread(String threadName, Runnable threadRunnable) + { + return createNewThread(threadName, false, threadRunnable); + } + + /** + * START's a new thread (Creates a new thread and runs that thread runnable on it) + * RUN's a new thread (Just executes the thread runnable on the active thread) + */ + public static Thread createNewThread(String threadName, boolean runDontStart, Runnable threadRunnable) { Thread temporaryThread = new Thread(threadRunnable, threadName); - temporaryThread.start(); + + if(runDontStart) + temporaryThread.run(); + else + temporaryThread.start(); return temporaryThread; }