|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.domian.util.concurrent.locks.SemaphoreSynchronizer
public final class SemaphoreSynchronizer
A Synchronizer
implementation using two Semaphore
instances.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface net.sourceforge.domian.util.concurrent.locks.Synchronizer |
---|
Synchronizer.MODE |
Constructor Summary | |
---|---|
SemaphoreSynchronizer()
|
Method Summary | ||
---|---|---|
|
callConcurrently(C callable)
Calls a Callable in a concurrent manner. |
|
|
callExclusively(C callable)
Calls a Callable in an exclusive manner. |
|
|
runConcurrently(R runnable)
Runs a Runnable in a concurrent manner. |
|
|
runExclusively(R runnable)
Runs a Runnable in an exclusive manner. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SemaphoreSynchronizer()
Method Detail |
---|
public <R extends java.lang.Runnable> void runConcurrently(R runnable)
Synchronizer
Runnable
in a concurrent manner.
runConcurrently
in interface Synchronizer
runnable
- the runnable to invoke concurrently, managed by this classpublic <T,C extends java.util.concurrent.Callable<T>> T callConcurrently(C callable)
Synchronizer
Callable
in a concurrent manner.
callConcurrently
in interface Synchronizer
callable
- the callable to invoke concurrently, managed by this class
Callable
's return value, or null
if no return valuepublic <R extends java.lang.Runnable> void runExclusively(R runnable)
Synchronizer
Runnable
in an exclusive manner.
Firstly, it will wait for all other exclusive Runnable
s and Callable
s to finish, if any.
Then it will wait for already running concurrent Runnable
s and Callable
s to finish, if any.
Finally it will run, queuing up all other Runnable
s and Callable
s managed by the same Synchronizer
instance.
When done, all queues are released.
runExclusively
in interface Synchronizer
runnable
- the runnable to invoke exclusively, managed by this classpublic <T,C extends java.util.concurrent.Callable<T>> T callExclusively(C callable)
Synchronizer
Callable
in an exclusive manner.
Firstly, it will wait for all other exclusive Runnable
s and Callable
s to finish, if any.
Then it will wait for already running concurrent Runnable
s and Callable
s to finish, if any.
Finally it will run, queuing up all other Runnable
s and Callable
s managed by the same Synchronizer
instance.
When done, all queues are released.
callExclusively
in interface Synchronizer
callable
- the callable to invoke exclusively, managed by this class
Callable
's return value, or null
if no return value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |