Class ThreadChecker

java.lang.Object
io.sentry.util.thread.ThreadChecker
All Implemented Interfaces:
IThreadChecker

@Internal public final class ThreadChecker extends Object implements IThreadChecker
Class that checks if a given thread is the Main/UI thread. The Main thread is denoted by the thread, where the `Sentry.init` method was called. If it was inited from a background thread, then this class is wrong, but it's a best effort.

We're gonna educate people through the docs.

  • Method Details

    • getInstance

      public static ThreadChecker getInstance()
    • isMainThread

      public boolean isMainThread(long threadId)
      Specified by:
      isMainThread in interface IThreadChecker
    • isMainThread

      public boolean isMainThread(@NotNull @NotNull Thread thread)
      Description copied from interface: IThreadChecker
      Checks if a given thread is the Main/UI thread
      Specified by:
      isMainThread in interface IThreadChecker
      Parameters:
      thread - the Thread
      Returns:
      true if it is the main thread or false otherwise
    • isMainThread

      public boolean isMainThread()
      Description copied from interface: IThreadChecker
      Checks if the calling/current thread is the Main/UI thread
      Specified by:
      isMainThread in interface IThreadChecker
      Returns:
      true if it is the main thread or false otherwise
    • isMainThread

      public boolean isMainThread(@NotNull @NotNull SentryThread sentryThread)
      Description copied from interface: IThreadChecker
      Checks if a given thread is the Main/UI thread
      Specified by:
      isMainThread in interface IThreadChecker
      Parameters:
      sentryThread - the SentryThread
      Returns:
      true if it is the main thread or false otherwise
    • currentThreadSystemId

      public long currentThreadSystemId()
      Description copied from interface: IThreadChecker
      Returns the system id of the current thread. Currently only used for Android.
      Specified by:
      currentThreadSystemId in interface IThreadChecker
      Returns:
      the current thread system id.