public interface ThreadBound
IllegalStateException will be thrown.
To marshal a call to the correct thread, you can use postAndWait(UncheckedCallable) or
postAndWait(Runnable), both of which complete synchronously.| Modifier and Type | Method and Description |
|---|---|
boolean |
checkThreadAccess()
Checks whether the current thread has access to this object.
|
void |
postAndWait(java.lang.Runnable r)
Synchronously executes a
Runnable on the thread that this object is bound to. |
<V> V |
postAndWait(UncheckedCallable<V> c)
Synchronously executes an
UncheckedCallable on the thread that this object is bound to,
and returns its result. |
void |
postDelayed(java.lang.Runnable r,
long delayMillis)
Asynchronously executes a
Runnable on the thread that this object is bound to
after the specified delay. |
void |
removeCallbacks(java.lang.Runnable r)
Removes any pending posts of the given
Runnable that are in the queue. |
void |
verifyThreadAccess()
Enforces that the current thread has access to this object.
|
boolean checkThreadAccess()
void verifyThreadAccess()
java.lang.IllegalStateException - if the current thread does not have access to this object<V> V postAndWait(UncheckedCallable<V> c)
UncheckedCallable on the thread that this object is bound to,
and returns its result.V - the return type of the UncheckedCallablec - the UncheckedCallable to executeUncheckedCallable.call()java.lang.RuntimeException - if the UncheckedCallable could not be executed (the cause
will be null), or if UncheckedCallable.call() threw an exception (the cause will be the
exception that it threw).void postAndWait(java.lang.Runnable r)
Runnable on the thread that this object is bound to.r - the Runnable to executejava.lang.RuntimeException - if the Runnable could not be executed (the cause will be
null), or if Runnable.run() threw an exception (the cause will be the exception that
it threw).void postDelayed(java.lang.Runnable r,
long delayMillis)
Runnable on the thread that this object is bound to
after the specified delay.r - the Runnable to executedelayMillis - The delay (in milliseconds) until the Runnable will be executed.java.lang.RuntimeException - if the Runnable could not be enqueued.void removeCallbacks(java.lang.Runnable r)
Runnable that are in the queue.r - the Runnable to remove from the queue