public final class EventRunner extends Object
After you call the run() method, the EventRunner will
continuously retrieve events from the event queue and dispatch the events to
the matching EventHandler. Then the
EventHandler#processEvent(InnerEvent) method will be called to
process the events.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static EventRunner |
create() |
Creates a thread and starts an
EventRunner. |
static EventRunner |
create(boolean inNewThread) |
Creates a thread and starts an
EventRunner with the
inNewThread parameter passed to specify who will manage the
EventRunner. |
static EventRunner |
create(String newThreadName) |
Creates a thread with the given name and starts an
EventRunner. |
static EventRunner |
current() |
Obtains the
EventRunner object bound to the current thread. |
void |
dump(Dumper dumper) |
Prints out the internal information about an object in the specified format,
helping you diagnose internal errors of the object.
|
static EventQueue |
getCurrentEventQueue() |
Obtains the event queue of the
EventRunner associated with the current thread. |
EventQueue |
getEventQueue() |
Obtains the event queue of this
EventRunner. |
static EventRunner |
getMainEventRunner() |
Obtains the
EventRunner for the main thread of the application. |
long |
getThreadId() |
Obtains the ID of the worker thread associated with this
EventRunner. |
boolean |
isCurrentRunnerThread() |
Checks whether the current thread is the worker thread of this
EventRunner. |
boolean |
run() |
Starts an
EventRunner that is not automatically managed by the
system. |
void |
setLogger(Logger logger) |
Sets the
Logger object for logging messages that are processed by this EventRunner. |
boolean |
stop() |
Stops an
EventRunner that is not automatically managed by the system. |
public static EventRunner current()
EventRunner object bound to the current thread.EventRunner object bound to the current thread;
returns null if no object is bound.public static EventRunner create()
EventRunner. The EventRunner
is automatically managed by the system by default.EventRunner in the new thread.public static EventRunner create(boolean inNewThread)
EventRunner with the
inNewThread parameter passed to specify who will manage the
EventRunner.inNewThread - Specifies whether the EventRunner will be
automatically managed by the system. The value
true indicates that it will be automatically
managed by the system, and the value false
indicates that it needs to be manually managed by
yourself.EventRunner in the new thread.public static EventRunner create(String newThreadName)
EventRunner. The
EventRunner is automatically managed by the system by default.newThreadName - Indicates the name of the new thread. If this parameter
is null or an empty string is passed, the default name
is used.EventRunner in the new thread.public void setLogger(Logger logger)
Logger object for logging messages that are processed by this EventRunner.logger - Indicates the Logger object you have implemented for logging messages.public void dump(Dumper dumper)
dumper - Indicates the Dumper object
you have implemented to process the output internal information.public static EventRunner getMainEventRunner()
EventRunner for the main thread of the application.
The EventRunner for the main thread (also referred to as the UI thread)
is generated by the system during application initialization.
EventRunner for the main thread of the application.public long getThreadId()
EventRunner.EventRunner.public boolean isCurrentRunnerThread()
EventRunner.true if the current thread is the worker thread of this EventRunner;
returns false otherwise.public EventQueue getEventQueue()
EventRunner.EventRunner.public static EventQueue getCurrentEventQueue()
EventRunner associated with the current thread.
This static method can be called from anywhere.
EventRunner associated with the current thread.public boolean run()
throws IllegalStateException
EventRunner that is not automatically managed by the
system. System-managed EventRunner objects are automatically started
by the system.true if the EventRunner is started; returns
false otherwise.IllegalStateException - Throws this exception if the
EventRunner is automatically managed by
the system.public boolean stop()
throws IllegalStateException
EventRunner that is not automatically managed by the system.
System-managed EventRunner objects are automatically stopped by the
system.true if the EventRunner is stopped; returns
false otherwise.IllegalStateException - Throws this exception if the
EventRunner is automatically managed by
the system.