Package i5.las2peer.tools
Class WaiterThread<T>
java.lang.Object
java.lang.Thread
i5.las2peer.tools.WaiterThread<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
Runnable
A simple thread waiting for a result.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptioncreate a new WaiterThread with a default timeout of 10 secondsWaiterThread
(int waitingTime) create a new waiter thread with an arbitrary time out value -
Method Summary
Modifier and TypeMethodDescriptionvoid
hand over an (occurred) exception to this WaiterThreadvoid
collectResult
(T result) hand over the result to this WaiterThreadboolean
has this thread collected an exception ?boolean
boolean
boolean
boolean
has this thread time out during waiting for a result?void
run()
the main waiting methodvoid
stop the main thread from waitingMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
WaiterThread
public WaiterThread(int waitingTime) create a new waiter thread with an arbitrary time out value- Parameters:
waitingTime
-
-
WaiterThread
public WaiterThread()create a new WaiterThread with a default timeout of 10 seconds
-
-
Method Details
-
run
public void run()the main waiting method -
stopWaiting
public void stopWaiting()stop the main thread from waiting -
collectResult
hand over the result to this WaiterThread- Parameters:
result
-
-
collectException
hand over an (occurred) exception to this WaiterThread- Parameters:
e
-
-
getResult
- Returns:
- the collected result, null, if no one has been
-
getException
- Returns:
- a collected exception (if any was collected)
-
isFinished
public boolean isFinished()- Returns:
- true, if the thread is finished
-
isSuccess
public boolean isSuccess()- Returns:
- true, if the thread is finished and a result is collected
-
hasResult
public boolean hasResult()- Returns:
- true, if a result has been collected
-
isTimedOut
public boolean isTimedOut()has this thread time out during waiting for a result?- Returns:
- true, if the thread is timed out without collecting a result
-
hasException
public boolean hasException()has this thread collected an exception ?- Returns:
- true, if an exception has been collected
-