From bf7a450be5b4895cdb41a194a8cc9c9b74718458 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 21 Jul 2024 16:38:47 +0200 Subject: [PATCH] Add Miscellaneous#onMainThread method --- .../sosengine/base/utility/Miscellaneous.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java b/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java index 7cccd01..6528576 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java @@ -163,4 +163,14 @@ public final class Miscellaneous { return separator; return null; } + + /** + * Ensures that the code is running on the main thread. + * + * @return {@code true} if running on the main thread, {@code false} otherwise + * @since v1-alpha2 + */ + public static boolean onMainThread() { + return Thread.currentThread().threadId() == 1; + } }