HandlerExecutor

class HandlerExecutor(tag: String?) : CloseableExecutor

HandlerExecutor internally manages a HandlerThread instance that will be used to execute incoming tasks in Executor.execute. HandlerExecutors are useful in places where an active Looper is required on the created Thread. The HandlerThread is assigned Process.THREAD_PRIORITY_BACKGROUND and should be only used to execute tasks with low priority.

Notes: The HandlerExecutor's internal HandlerThread event loop is stopped when close is called.

    As a good practice, always `close` the executor when it is no longer required.

Parameters

tag

The thread name of the handler thread that will be created.

Constructors

HandlerExecutor
Link copied to clipboard
fun HandlerExecutor(tag: String? = null)
The thread name of the handler thread that will be created.

Functions

close
Link copied to clipboard
open override fun close()
Releases any internal resources that are used by this executor.
execute
Link copied to clipboard
open override fun execute(command: Runnable)
Executes the given command in an HandlerThread that is guranteed to have a Looper running actively.