Class GridTestSafeThreadFactory

  • All Implemented Interfaces:
    ThreadFactory

    public final class GridTestSafeThreadFactory
    extends Object
    implements ThreadFactory
    Threads factory for safe test-threads management.
    • Constructor Detail

      • GridTestSafeThreadFactory

        public GridTestSafeThreadFactory​(String threadName)
        Constructs threads factory for safe test-threads management.
        Parameters:
        threadName - threads name prefix.
      • GridTestSafeThreadFactory

        public GridTestSafeThreadFactory​(String threadName,
                                         boolean interruptAll)
        Constructs threads factory for safe test-threads management.
        Parameters:
        threadName - Threads name prefix.
        interruptAll - Interrupt all threads in factory if any thread fails with unexpected exception.
    • Method Detail

      • newThread

        public Thread newThread​(Callable<?> c)
        Create new thread around callable task.
        Parameters:
        c - Callable task to execute in the thread.
        Returns:
        New thread around callable task.
        See Also:
        GridTestThread
      • newThread

        public Thread newThread​(Runnable r)
        Create new thread around runnable task.
        Specified by:
        newThread in interface ThreadFactory
        Parameters:
        r - Runnable task to execute in the thread.
        Returns:
        New thread around runnable task.
        See Also:
        GridTestThread
      • checkError

        public void checkError()
                        throws Exception
        Check and throws an exception if happens during this factory threads execution.
        Throws:
        Exception - If there is error.
      • interruptAllThreads

        public void interruptAllThreads()
        Interrupts all threads, created by this thread factory.