Android英文文档翻译系列(2)——HandlerThread

来源:互联网 发布:淘宝会员要钱吗 编辑:程序博客网 时间:2024/04/25 13:23
 
public class
 
HandlerThread
extends Thread
 
Class  Overview
Handy class for starting a new thread that has a looper.The looper can than be used to create handler classes.Note that start() mast still not called.
 
Handy class for starting a new thread that has a looper.
//这是一个可以很便捷地获取一个Looper来开启一个新线程的类。(这是一个方便创建新线程并拥有looper的类)
The looper can than be used to create handler classes.
//可以利用这个looper创建一盒Handler类。(也就是带looper的handler)
Note that start() mast still not called.
//注意此时start()方法还没调用。
 
Public Constructor//公共构造器
public HandlerThread(String name)
public HandlerThread(String name,int priority)
parameters //参数
priority The priority to run the thread at.The values supplied must be from Procces and not from java.lang.Thread.
//优先级 这个优先级是运行在线程里的,它的值必须是是进程中支持的而非线程。
 
Public Method
public Looper getLooper()
The method returns the looper associated whit this thread.If this thread not been started or for any reason is Alive() returns false,this method will return null.If this thread has been started,this method will brock until the looper has been initialized.
 
The method returns the looper associated whit this thread.
//这个方法将会返回一个和线程关联的looper。
If this thread not been started or for any reason is isAlive() returns false,this method will return null.
//如果这个线程没被执行或者由于任何原因 isAlive()返回假的时候,这个方法将会返回空。
If this thread has been started,this method will brock until the looper has been initialized.
//如果这个线程已经开始运行了,这个方法将会阻塞除非looper已经被初始化。
 
public int getThreadId()
Retunrs the ind identifier of this thread.See Procces.myPid.
//返回这个线程的标识符,见Procces.myPid。
 
public boolean quit()
Ask the currenty running looper to quit.If this thread has not been started or has finished(that is if getLooper() returns null),then false is returned.Otherwise  the looper is asked quit and true is return.
//呼叫当前正在运行中的looper消息循环退出。如果这个线程没有开始或者线程已经执行完毕(getLooper 将返回空),就返回假。否则将退出消息循环并返回真。
 
public void run()
Calls the run() method of the Runnable object the receiver holds.If no Runnable set,does nothing.
//Runnable 对象调用这个方法...不懂,如果没有对象设置,就不做任何事。
0 0
原创粉丝点击