public abstract class IlSynchronizationStrategy extends Object
IlSwingThreadSyncStrategy
for Swing-based applicationsIlSynchronizeOnLockStrategy
to synchronize on a mutexThis class also provides a default synchronization strategy. This default strategy can be changed by using the SetDefault function, or by using the ilog.mt.IlSynchronization.Strategy.Default system property. For example, to use IlSynchronizOnLockStrategy, launch your java application with the command: java -Dilog.mt.IlSynchronization.Strategy.Default=ilog.mt.IlSynchronizOnLockStrategy Aprogram
If no default property is set when GetDefault is first called, then the IlSwingThreadSyncStrategy class will be loaded and used as the default strategy.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PROPERTY
System property name:
ilog.mt.IlSynchronization.Strategy.Default
The property value specifies the synchronization strategy class. |
Modifier | Constructor and Description |
---|---|
protected |
IlSynchronizationStrategy()
Instantiates a new synchronization strategy.
|
Modifier and Type | Method and Description |
---|---|
static IlSynchronizationStrategy |
GetDefault()
Gets the default strategy to use.
|
boolean |
isInTargetThread()
Returns
true if currently executing in the target thread of this strategy. |
boolean |
readLock(Runnable runnable,
Object lock)
Acquires a read lock for the current thread and calls run on the
Runnable object passed. |
static void |
SetDefault(IlSynchronizationStrategy defaultStrategy)
Change the default strategy to use.
|
abstract boolean |
synchronizeRun(Runnable runnable,
Object locker)
Synchronizes the current thread and calls run on the
Runnable object passed. |
boolean |
writeLock(Runnable runnable,
Object lock)
Acquires a write lock for the current thread and calls run on the
Runnable object passed. |
public static final String DEFAULT_PROPERTY
ilog.mt.IlSynchronization.Strategy.Default
The property value specifies the synchronization strategy class. An instance of this class is created and used as the default one, if a synchronization strategy is not specified in the application deployment descriptor.
protected IlSynchronizationStrategy()
public static void SetDefault(IlSynchronizationStrategy defaultStrategy)
defaultStrategy
- The new default strategypublic static IlSynchronizationStrategy GetDefault()
public abstract boolean synchronizeRun(Runnable runnable, Object locker)
Runnable
object passed.
Depending on the implementation of the strategy, the synchronization may be global
(such as in a Swing application) or may use the object passed as the lock parameter
to synchronize on.runnable
- The Runnable
object on which the run method will be calledlocker
- This object may be used as the object to synchronize onfalse
if the operation fails for any reason.public boolean readLock(Runnable runnable, Object lock)
Runnable
object passed.
Some implementations may not support read/write locks. For this reason, the default
implementation will call the synchronizeRun
method.runnable
- The Runnable
object on which the run method will be calledlock
- This object may be used as the object to synchronize onpublic boolean writeLock(Runnable runnable, Object lock)
Runnable
object passed.
Some implementations may not support read/write locks. For this reason, the default
implementation will call the synchronizeRun
method.runnable
- The Runnable
object on which the run method will be calledlock
- This object may be used as the object to synchronize onpublic boolean isInTargetThread()
true
if currently executing in the target thread of this strategy.
Returns false
if not in the target thread, or if this strategy has no target thread.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.