Package org.apache.ignite.testframework
Class GridTestSafeThreadFactory
- java.lang.Object
-
- org.apache.ignite.testframework.GridTestSafeThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public final class GridTestSafeThreadFactory extends Object implements ThreadFactory
Threads factory for safe test-threads management.
-
-
Constructor Summary
Constructors Constructor Description GridTestSafeThreadFactory(String threadName)
Constructs threads factory for safe test-threads management.GridTestSafeThreadFactory(String threadName, boolean interruptAll)
Constructs threads factory for safe test-threads management.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkError()
Check and throws an exception if happens during this factory threads execution.void
interruptAllThreads()
Interrupts all threads, created by this thread factory.Thread
newThread(Runnable r)
Create new thread around runnable task.Thread
newThread(Callable<?> c)
Create new thread around callable task.
-
-
-
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 interfaceThreadFactory
- 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.
-
-