public abstract class AbstractLooper extends Object implements ManagedLifeCycle, Looper
continuous and periodic modes
are supported; see LooperThread for details.
In sample code Processor uses a user defined iteration period. It is also possible to run into
continuous mode in which case Looper.loop() should wait for some IO events or explicit sleep.
public class Processor extends AbstractLooper
{
public Processor()
{
super(PERIOD);
}
@Override
public void loop() throws IOException
{
// implements loop iteration logic
}
}
| Modifier and Type | Field and Description |
|---|---|
protected LooperThread |
thread
Looper thread created, started and stopped by this abstract looper.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLooper()
Construct a looper instance operating in
continuous modes. |
protected |
AbstractLooper(int period)
Construct a looper instance operation in
periodic mode. |
| Modifier and Type | Method and Description |
|---|---|
void |
postConstruct()
Start looper thread.
|
void |
preDestroy()
Stop looper thread.
|
protected final LooperThread thread
protected AbstractLooper()
continuous modes. Looper.loop() implementation should
wait for some IO events or explicit sleep to avoid abusing the thread.protected AbstractLooper(int period)
periodic mode.period - loop iteration period, in milliseconds.IllegalArgumentException - if period argument is not strict positive.public void postConstruct()
throws Exception
postConstruct in interface ManagedLifeCyclepostConstruct in interface ManagedPostConstructException - exceptions from application defined post-construct logic are bubbled up.public void preDestroy()
throws Exception
preDestroy in interface ManagedLifeCyclepreDestroy in interface ManagedPreDestroyException - exceptions from application defined clean-up logic are bubbled up.Copyright © 2018. All rights reserved.