# MainThread

Summary:[Inherited Methods](https://developer.android.com/reference/android/support/annotation/MainThread#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/annotation/MainThread#)  

# MainThread

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


abstract
@interface
MainThread
`  
`


implements

Annotation


`

|---------------------------------------|
| android.support.annotation.MainThread |

<br />

*** ** * ** ***

Denotes that the annotated method should only be called on the main thread. If the annotated element is a class, then all methods in the class should be called on the main thread.

Example:  


      @MainThread
      public void deliverResult(D data) { ... }
     
**Note:** Ordinarily, an app's main thread is also the UI thread. However, under special circumstances, an app's main thread might not be its UI thread; for more information, see[Thread annotations](https://developer.android.com/studio/write/annotations#thread-annotations).  
**See also:**

- [UiThread](https://developer.android.com/reference/android/support/annotation/UiThread)

## Summary

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/annotation/MainThread#)From interface` java.lang.annotation.Annotation ` |-----------------------------------------|-------------------------| | ` abstract Class<? extends Annotation>` | ` annotationType() `    | | ` abstract boolean`                     | ` equals(Object arg0) ` | | ` abstract int`                         | ` hashCode() `          | | ` abstract String`                      | ` toString() `          | ||

-

  ## Annotations

  - [AnimatorRes](https://developer.android.com/reference/android/support/annotation/AnimatorRes)
  - [AnimRes](https://developer.android.com/reference/android/support/annotation/AnimRes)
  - [AnyRes](https://developer.android.com/reference/android/support/annotation/AnyRes)
  - [AnyThread](https://developer.android.com/reference/android/support/annotation/AnyThread)
  - [ArrayRes](https://developer.android.com/reference/android/support/annotation/ArrayRes)
  - [AttrRes](https://developer.android.com/reference/android/support/annotation/AttrRes)
  - [BinderThread](https://developer.android.com/reference/android/support/annotation/BinderThread)
  - [BoolRes](https://developer.android.com/reference/android/support/annotation/BoolRes)
  - [CallSuper](https://developer.android.com/reference/android/support/annotation/CallSuper)
  - [CheckResult](https://developer.android.com/reference/android/support/annotation/CheckResult)
  - [ColorInt](https://developer.android.com/reference/android/support/annotation/ColorInt)
  - [ColorLong](https://developer.android.com/reference/android/support/annotation/ColorLong)
  - [ColorRes](https://developer.android.com/reference/android/support/annotation/ColorRes)
  - [DimenRes](https://developer.android.com/reference/android/support/annotation/DimenRes)
  - [Dimension](https://developer.android.com/reference/android/support/annotation/Dimension)
  - [DrawableRes](https://developer.android.com/reference/android/support/annotation/DrawableRes)
  - [FloatRange](https://developer.android.com/reference/android/support/annotation/FloatRange)
  - [FontRes](https://developer.android.com/reference/android/support/annotation/FontRes)
  - [FractionRes](https://developer.android.com/reference/android/support/annotation/FractionRes)
  - [GuardedBy](https://developer.android.com/reference/android/support/annotation/GuardedBy)
  - [HalfFloat](https://developer.android.com/reference/android/support/annotation/HalfFloat)
  - [IdRes](https://developer.android.com/reference/android/support/annotation/IdRes)
  - [IntDef](https://developer.android.com/reference/android/support/annotation/IntDef)
  - [IntegerRes](https://developer.android.com/reference/android/support/annotation/IntegerRes)
  - [InterpolatorRes](https://developer.android.com/reference/android/support/annotation/InterpolatorRes)
  - [IntRange](https://developer.android.com/reference/android/support/annotation/IntRange)
  - [Keep](https://developer.android.com/reference/android/support/annotation/Keep)
  - [LayoutRes](https://developer.android.com/reference/android/support/annotation/LayoutRes)
  - [LongDef](https://developer.android.com/reference/android/support/annotation/LongDef)
  - [MainThread](https://developer.android.com/reference/android/support/annotation/MainThread)
  - [MenuRes](https://developer.android.com/reference/android/support/annotation/MenuRes)
  - [NavigationRes](https://developer.android.com/reference/android/support/annotation/NavigationRes)
  - [NonNull](https://developer.android.com/reference/android/support/annotation/NonNull)
  - [Nullable](https://developer.android.com/reference/android/support/annotation/Nullable)
  - [PluralsRes](https://developer.android.com/reference/android/support/annotation/PluralsRes)
  - [Px](https://developer.android.com/reference/android/support/annotation/Px)
  - [RawRes](https://developer.android.com/reference/android/support/annotation/RawRes)
  - [RequiresApi](https://developer.android.com/reference/android/support/annotation/RequiresApi)
  - [RequiresPermission](https://developer.android.com/reference/android/support/annotation/RequiresPermission)
  - [RequiresPermission.Read](https://developer.android.com/reference/android/support/annotation/RequiresPermission.Read)
  - [RequiresPermission.Write](https://developer.android.com/reference/android/support/annotation/RequiresPermission.Write)
  - [RestrictTo](https://developer.android.com/reference/android/support/annotation/RestrictTo)
  - [Size](https://developer.android.com/reference/android/support/annotation/Size)
  - [StringDef](https://developer.android.com/reference/android/support/annotation/StringDef)
  - [StringRes](https://developer.android.com/reference/android/support/annotation/StringRes)
  - [StyleableRes](https://developer.android.com/reference/android/support/annotation/StyleableRes)
  - [StyleRes](https://developer.android.com/reference/android/support/annotation/StyleRes)
  - [TransitionRes](https://developer.android.com/reference/android/support/annotation/TransitionRes)
  - [UiThread](https://developer.android.com/reference/android/support/annotation/UiThread)
  - [VisibleForTesting](https://developer.android.com/reference/android/support/annotation/VisibleForTesting)
  - [WorkerThread](https://developer.android.com/reference/android/support/annotation/WorkerThread)
  - [XmlRes](https://developer.android.com/reference/android/support/annotation/XmlRes)
-

  ## Enums

  - [RestrictTo.Scope](https://developer.android.com/reference/android/support/annotation/RestrictTo.Scope)