Interface OnThreadCompletedListener
-
- All Known Implementing Classes:
AbstractPooling
,LambdasPooling
,NormalPooling
,NotEnoughCapacity
public interface OnThreadCompletedListener
Interface that classes that want to get notified byNotifyingThread
must implement.OnThreadCompletedListener
provides an easy access method for classes to get notified when aNotifyingThread
finishes.This listener is useful for both:
-
Handling finished threads, by using the
Runnable
param included always with this method call. ThatRunnable
will have the just finished thread, and cannot benull
(refer toNotifyingThread.run()
for more information). -
Managing exceptions: by default,
NotifyingThread
manages the unhandled exceptions by itself, when creating a new instance, assigning the method call to itself, for managing and including the exception when it happens while executing the thread. Refer toNotifyingThread.uncaughtException(Thread, Throwable)
for more information.
At any time you can override the uncaught exception handler for setting up a custom behaviour, knowing that, when an exception occurs,
onThreadCompletedListener(Thread, Throwable)
will not be called.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onThreadCompletedListener(java.lang.Thread thread, java.lang.Throwable exception)
When a thread finish its execution, if using aNotifyingThread
and the class is subscribed, this method is called, with theRunnable
which corresponds the just finished thread, and theThrowable
containing the exception (if any exception has benn thrown).
-
-
-
Method Detail
-
onThreadCompletedListener
void onThreadCompletedListener(@NotNull java.lang.Thread thread, @Nullable java.lang.Throwable exception)
When a thread finish its execution, if using aNotifyingThread
and the class is subscribed, this method is called, with theRunnable
which corresponds the just finished thread, and theThrowable
containing the exception (if any exception has benn thrown).Refer to
NotifyingThread.addOnThreadCompletedListener(OnThreadCompletedListener)
for getting more information about subscribing classes.- Parameters:
thread
- the thread that has just finished its execution.exception
- the exception if happened, elsenull
.
-
-