Interface OnThreadCompletedListener

  • All Known Implementing Classes:
    AbstractPooling, LambdasPooling, NormalPooling, NotEnoughCapacity

    public interface OnThreadCompletedListener
    Interface that classes that want to get notified by NotifyingThread must implement.

    OnThreadCompletedListener provides an easy access method for classes to get notified when a NotifyingThread finishes.

    This listener is useful for both:

    • Handling finished threads, by using the Runnable param included always with this method call. That Runnable will have the just finished thread, and cannot be null (refer to NotifyingThread.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 to NotifyingThread.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 a NotifyingThread and the class is subscribed, this method is called, with the Runnable which corresponds the just finished thread, and the Throwable 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 a NotifyingThread and the class is subscribed, this method is called, with the Runnable which corresponds the just finished thread, and the Throwable 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, else null.