public class ThreadDispatcher extends Object implements Task.Dispatcher
Use attach(Handler) to set an existing handler, which is used to schedule task
with the executor.
TAG| 构造器和说明 |
|---|
ThreadDispatcher(int threadPoolSize) |
ThreadDispatcher(int threadPoolSize,
int capacity) |
| 限定符和类型 | 方法和说明 |
|---|---|
ThreadDispatcher |
attach(android.os.Handler scheduler)
Attach an existing scheduler to dispatcher, so that we don't need to create an new one.
|
void |
finish(Runnable runnable)
When a task is finished, it will call this method.
|
boolean |
has(int what)
Check if there exists the task with the specific id.
|
boolean |
has(Runnable runnable)
Check if there exists the task with the specific runnable.
|
boolean |
isRunning()
Whether or not the dispatcher is working.
|
void |
post(int what,
Runnable runnable)
Add an task to the dispatcher with id.
|
void |
post(Runnable runnable)
Add an task to the dispatcher.
|
void |
postDelay(int what,
Runnable runnable,
long millis)
Schedule an task to the dispatcher with id.
|
void |
postDelay(Runnable runnable,
long millis)
Schedule an task to the dispatcher.
|
void |
shutdown()
Terminate the dispatcher.
|
void |
start()
Start the dispatcher before it can work.
|
public ThreadDispatcher(int threadPoolSize)
public ThreadDispatcher(int threadPoolSize,
int capacity)
public ThreadDispatcher attach(android.os.Handler scheduler)
Task.Dispatcherattach 在接口中 Task.Dispatcherpublic void start()
Task.Dispatcherstart 在接口中 Task.Dispatcherpublic boolean isRunning()
Task.DispatcherisRunning 在接口中 Task.Dispatcherpublic void post(Runnable runnable)
Task.Dispatcherpost 在接口中 Task.Dispatcherpublic void post(int what,
Runnable runnable)
Task.Dispatcherpost 在接口中 Task.Dispatcherpublic void postDelay(Runnable runnable, long millis)
Task.DispatcherpostDelay 在接口中 Task.Dispatcherpublic void postDelay(int what,
Runnable runnable,
long millis)
Task.DispatcherpostDelay 在接口中 Task.Dispatcherpublic boolean has(int what)
Task.Dispatcherhas 在接口中 Task.Dispatcherpublic boolean has(Runnable runnable)
Task.Dispatcherhas 在接口中 Task.Dispatcherpublic void finish(Runnable runnable)
Task.Dispatcherfinish 在接口中 Task.Dispatcherpublic void shutdown()
Task.Dispatchershutdown 在接口中 Task.Dispatcher