@UnstableApi
public final class ThreadTestUtil


Static utility to coordinate threads in testing environments.

Summary

Public methods

static void
registerThreadIsBlockedUntilProgressOnLooper(
    ConditionVariable conditionVariable,
    Looper looper
)

Registers that the current thread will be blocked with the provided ConditionVariable until the specified Looper reports to have made progress via unblockThreadsWaitingForProgressOnCurrentLooper.

static void

Unblocks any threads that are waiting for progress on the current Looper thread.

Public methods

registerThreadIsBlockedUntilProgressOnLooper

public static void registerThreadIsBlockedUntilProgressOnLooper(
    ConditionVariable conditionVariable,
    Looper looper
)

Registers that the current thread will be blocked with the provided ConditionVariable until the specified Looper reports to have made progress via unblockThreadsWaitingForProgressOnCurrentLooper.

Parameters
ConditionVariable conditionVariable

The ConditionVariable that will block the current thread.

Looper looper

The Looper that must report progress to unblock the current thread. Must not be the Looper of the current thread.

unblockThreadsWaitingForProgressOnCurrentLooper

public static void unblockThreadsWaitingForProgressOnCurrentLooper()

Unblocks any threads that are waiting for progress on the current Looper thread.