# BackgroundExecutor

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/util/BackgroundExecutor "View this page in Java")

<br />

```
@UnstableApi
class BackgroundExecutor
```

<br />

*** ** * ** ***

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

## Summary

|                                                 ### Public functions                                                 |
|----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `synchronized java-static `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!` | [get](https://developer.android.com/reference/kotlin/androidx/media3/common/util/BackgroundExecutor#get())`()` Returns an[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)for background tasks.                                                                                                                                                                                                                                        |
| `synchronized java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)             | [set](https://developer.android.com/reference/kotlin/androidx/media3/common/util/BackgroundExecutor#set(java.util.concurrent.Executor))`(executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!)` Sets the[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)to be returned from[get](https://developer.android.com/reference/kotlin/androidx/media3/common/util/BackgroundExecutor#get()). |

## Public functions

### get

```
synchronized java-static fun get(): Executor!
```

Returns an[Executor](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 java-static fun set(executor: Executor!): Unit
```

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

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

|                                              Parameters                                               |
|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!` | An[Executor](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. |