Add Miscellaneous#onMainThread method
This commit is contained in:
parent
3964512979
commit
bf7a450be5
1 changed files with 10 additions and 0 deletions
|
@ -163,4 +163,14 @@ public final class Miscellaneous {
|
||||||
return separator;
|
return separator;
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue