Constructor and Description |
---|
LockedExecutor(Sync mutex)
Create a new LockedExecutor that relies on the given mutual
exclusion lock.
|
Modifier and Type | Method and Description |
---|---|
void |
execute(java.lang.Runnable command)
Execute the given command directly in the current thread,
within the supplied lock.
|
protected final Sync mutex_
public LockedExecutor(Sync mutex)
mutex
- Any mutual exclusion lock.
Standard usage is to supply an instance of Mutex
,
but, for example, a Semaphore initialized to 1 also works.
On the other hand, many other Sync implementations would not
work here, so some care is required to supply a sensible
synchronization object.