# BackgroundExecutor

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/BackgroundExecutor.java+class:androidx.media3.common.util.BackgroundExecutor)

*** ** * ** ***


```
@UnstableApi
public final class BackgroundExecutor
```

<br />

*** ** * ** ***

A utility class to obtain an `https://developer.android.com/reference/java/util/concurrent/Executor.html` for background tasks.

## Summary

| ### Public methods |
|---|---|
| `synchronized static https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/media3/common/util/BackgroundExecutor#get()()` Returns an `https://developer.android.com/reference/java/util/concurrent/Executor.html` for background tasks. |
| `synchronized static void` | `https://developer.android.com/reference/androidx/media3/common/util/BackgroundExecutor#set(java.util.concurrent.Executor)(https://developer.android.com/reference/java/util/concurrent/Executor.html executor)` Sets the `https://developer.android.com/reference/java/util/concurrent/Executor.html` to be returned from `https://developer.android.com/reference/androidx/media3/common/util/BackgroundExecutor#get()`. |

## Public methods

### get

```
synchronized public static Executor get()
```

Returns an `https://developer.android.com/reference/java/util/concurrent/Executor.html` for background tasks.

Must only be used for quick, high-priority tasks to ensure other background tasks are not blocked.

The thread is guaranteed to be alive for the lifetime of the application.

### set

```
synchronized public static void set(Executor executor)
```

Sets the `https://developer.android.com/reference/java/util/concurrent/Executor.html` to be returned from `https://developer.android.com/reference/androidx/media3/common/util/BackgroundExecutor#get()`.

Note that the thread of the provided `https://developer.android.com/reference/java/util/concurrent/Executor.html` must stay alive for the lifetime of the application.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` that runs tasks on background threads and should only be used for quick, high-priority tasks to ensure other background tasks are not blocked. |