T
- The Java Generic of type "T" is explicitly defined at compile-time.
public class Implementor<T> extends MethodBlockingTask<ConcreteClass>{ }
public abstract class MethodBlockingTask<T> extends RetrievableTask<T>
MethodBlockingTask
blocks retrieve()
until the execute()
method has fully completed and terminated.printThreadIdFlag
Modifier | Constructor and Description |
---|---|
protected |
MethodBlockingTask() |
Modifier and Type | Method and Description |
---|---|
protected void |
accept(T obj)
Sets the value of the
obj in a ThreadSafe manner. |
protected abstract void |
execute()
The execute() method allows clients to execute the business logic associated
with the respective
Task . |
T |
retrieve()
Returns the value of the object once the
execute() method has returned,
as set by the accept(Object) method. |
void |
run() |
getName, getPriority, getThreadId, setName, setPriority
public final void run()
AbstractTask
run
in interface Runnable
run
in class AbstractTask<T>
protected abstract void execute()
AbstractTask
Task
.execute
in class AbstractTask<T>
protected final void accept(T obj)
RetrievableTask
obj
in a ThreadSafe
manner.accept
in class RetrievableTask<T>
obj
- The object to set.public final T retrieve() throws InterruptedException
Returns the value of the object once the execute()
method has returned,
as set by the accept(Object)
method.
From the parent document:
Returns the value of the obj
in a ThreadSafe
manner. The method blocks until a condition is
met (such as the excute() method returning or the obj
of type <T> being set (via the setVal()
method). For more information on the way internal contention is handled, please refer to
MethodBlockingTask
and ObjectBlockingTask
.
public class TaskImplementor<T> implements Task<ConcreteClass>{ }
Note that compile-time type checking is enabled. The usage of Java Generics nullifies the compiler warning "unchecked".
retrieve
in class RetrievableTask<T>
InterruptedException
- is thrown if the thread is interrupted.ObjectBlockingTask
,
MethodBlockingTask
Copyright © 2020. All rights reserved.