|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.curjent.agent.ReusableTask
public class ReusableTask
Source for a task that can be used concurrently by multiple threads. Since one task is used by multiple threads, the task is responsible for synchronizing access to any mutable state.
This implementation is not thread-safe.
| Constructor Summary | |
|---|---|
ReusableTask(Object task,
int max)
Initializes this instance with the one reusable task and the maximum number of times it can be acquired. |
|
| Method Summary | |
|---|---|
Object |
acquire()
Increments the number of outstanding acquires and returns the reusable task. |
void |
release(Object task)
Decrements the number of outstanding acquires. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReusableTask(Object task,
int max)
max is greater than
1, the given task must be thread-safe.
NullPointerException - task is null.
IllegalArgumentException - max is 0 or
negative.| Method Detail |
|---|
public Object acquire()
throws Throwable
null if max has been reached.
acquire in interface AgentTasksThrowable - An unexpected error.Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)
public void release(Object task)
throws Throwable
release in interface AgentTasksIllegalStateException - The given task is not the same
as the task this instance was constructed with.
IllegalStateException - The number of releases has exceeded the
number of outstanding acquires.
Throwable - An unexpected error.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||