Class RunAndWaitUtil


  • public final class RunAndWaitUtil
    extends Object
    • Method Detail

      • runAndWait

        public static <R> R runAndWait​(Object pCurrentThreadId,
                                       Object pDestThreadId,
                                       Consumer<Runnable> pRunOnThread,
                                       Callable<R> pCallable)
                                throws Exception
        Runs the specified callable on the specified thread and waits for the result. This method allows pseudo-recursive invocations. Example: run on Thread1, from Thread1 run on Thread2, from Thread2 run on Thread1, etc.
        Parameters:
        pCurrentThreadId - The ID of the current thread.
        pDestThreadId - The ID of the thread on which the specified callable should be executed.
        pRunOnThread - Consumer which executes (without waiting) the specified runnable on the thread with ID pDestThreadId.
        pCallable - The callable to be run on the thread with ID pDestThreadId.
        Returns:
        The result of the specified callable.
        Throws:
        Exception