# ThreadTestUtil

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

*** ** * ** ***


```
@UnstableApi
public final class ThreadTestUtil
```

<br />

*** ** * ** ***

Static utility to coordinate threads in testing environments.

## Summary

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#registerThreadIsBlockedUntilProgressOnLooper(androidx.media3.common.util.ConditionVariable,android.os.Looper)( https://developer.android.com/reference/androidx/media3/common/util/ConditionVariable conditionVariable, https://developer.android.com/reference/android/os/Looper.html looper )` Registers that the current thread will be blocked with the provided `https://developer.android.com/reference/androidx/media3/common/util/ConditionVariable` until the specified `https://developer.android.com/reference/android/os/Looper.html` reports to have made progress via `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()()` Unblocks any threads that are waiting for progress on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnLooper(android.os.Looper)(https://developer.android.com/reference/android/os/Looper.html looper)` Unblocks any threads that are waiting for progress on the specified `https://developer.android.com/reference/android/os/Looper.html` thread. |

## Public methods

### registerThreadIsBlockedUntilProgressOnLooper

```
public static void registerThreadIsBlockedUntilProgressOnLooper(
    ConditionVariable conditionVariable,
    Looper looper
)
```

Registers that the current thread will be blocked with the provided `https://developer.android.com/reference/androidx/media3/common/util/ConditionVariable` until the specified `https://developer.android.com/reference/android/os/Looper.html` reports to have made progress via `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ConditionVariable conditionVariable` | The `https://developer.android.com/reference/androidx/media3/common/util/ConditionVariable` that will block the current thread. |
| `https://developer.android.com/reference/android/os/Looper.html looper` | The `https://developer.android.com/reference/android/os/Looper.html` that must report progress to unblock the current thread. Must not be the `https://developer.android.com/reference/android/os/Looper.html` of the current thread. |

### unblockThreadsWaitingForProgressOnCurrentLooper

```
public static void unblockThreadsWaitingForProgressOnCurrentLooper()
```

Unblocks any threads that are waiting for progress on the current `https://developer.android.com/reference/android/os/Looper.html` thread.

### unblockThreadsWaitingForProgressOnLooper

```
public static void unblockThreadsWaitingForProgressOnLooper(Looper looper)
```

Unblocks any threads that are waiting for progress on the specified `https://developer.android.com/reference/android/os/Looper.html` thread.