Add Miscellaneous#onMainThread method

This commit is contained in:
JeremyStar™ 2024-07-21 16:38:47 +02:00
parent 3964512979
commit bf7a450be5
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -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;
}
}