public final class SynchronizationExecutor extends Object
SynchronizationBlock
that synchronized more then one threads by one value.
For synchronization by one value call execute(SynchronizationBlock, String, Object)
, where in method
SynchronizationBlock.syncBlock()
are code that will be synchronized by value. If synchronization block part
has no result than use SynchronizationNoResultBlock.syncBlockNoResult()
.
Attribute syncValueType must be unique for domain which will be by value (syncValue) synchronized (like THROTTLING, or ALERT_COUNT).
Example:
In this example increment for property count is synchronized by value SYNCHRONIZATION_VALUE in domain ALERT.
Method has no result.
int count = 0;
String synchronizationValue = "SYNCHRONIZATION_VALUE";
SynchronizationExecutor.getInstance().execute(new SynchronizationNoResultBlock() {
@Override
protected void syncBlockNoResult() {
count++;
}
}, "ALERT", synchronizationValue);
Instance of this class gets by getInstance()
.
SynchronizationBlock
,
SynchronizationNoResultBlock
Modifier and Type | Method and Description |
---|---|
<T> T |
execute(SynchronizationBlock syncBlock,
String syncValueType,
Object syncValue)
Execute method
SynchronizationBlock.syncBlock() in synchronization by one value
(attribute syncValue). |
static SynchronizationExecutor |
getInstance()
Gets instance of this class.
|
public <T> T execute(SynchronizationBlock syncBlock, String syncValueType, Object syncValue)
SynchronizationBlock.syncBlock()
in synchronization by one value
(attribute syncValue).
Attribute syncValueType must be unique for domain which will be by value (syncValue) synchronized (like THROTTLING, or ALLERT_COUNT).
T
- type of return objectsyncBlock
- interface with method SynchronizationBlock.syncBlock()
that
will be synchronized by valuesyncValueType
- type of value (like THROTTLING is synchronized every throttling scopes)syncValue
- value by which will be method synchronized (like concrete throttling scope)SynchronizationBlock.syncBlock()
public static SynchronizationExecutor getInstance()
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.