android.os
Class HandlerThread
java.lang.Object
java.lang.Thread
android.os.HandlerThread
- All Implemented Interfaces:
- Runnable
public class HandlerThread
- extends Thread
Handy class for starting a new thread that has a looper. The looper can then be
used to create handler classes. Note that start() must still be called.
|
Method Summary |
Looper |
getLooper()
This method returns the Looper associated with this thread. |
int |
getThreadId()
Returns the identifier of this thread. |
protected void |
onLooperPrepared()
Call back method that can be explicitly over ridden if needed to execute some
setup before Looper loops. |
void |
run()
Calls the run() method of the Runnable object the receiver
holds. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
HandlerThread
public HandlerThread(String name)
HandlerThread
public HandlerThread(String name,
int priority)
- Constructs a HandlerThread.
- Parameters:
name - priority - The priority to run the thread at. The value supplied must be from
Process and not from java.lang.Thread.
onLooperPrepared
protected void onLooperPrepared()
- Call back method that can be explicitly over ridden if needed to execute some
setup before Looper loops.
run
public void run()
- Description copied from class:
Thread
- Calls the
run() method of the Runnable object the receiver
holds. If no Runnable is set, does nothing.
- Specified by:
run in interface Runnable- Overrides:
run in class Thread
- See Also:
Thread.start()
getLooper
public Looper getLooper()
- This method returns the Looper associated with this thread. If this thread not been started
or for any reason is isAlive() returns false, this method will return null. If this thread
has been started, this method will blocked until the looper has been initialized.
- Returns:
- The looper.
getThreadId
public int getThreadId()
- Returns the identifier of this thread. See Process.myTid().
Please submit a feedback, bug or feature