构造方法 | 说明 |
Thread() |
分配新的 Thread 对象 |
Thread(Runnable target) |
分配新的 Thread 对象, target 为 run() 方法被调用的对象 |
Thread(Runnable target,String name) |
分配新的 Thread 对象, target 为 run() 方法被调用的对象, name为新线程的名称 |
void run() |
执行任务操作的方法 |
void start() |
使该线程开始执行, Java虚拟机调用该线程的 run() 方法 |
void sleep(long millis) |
在指定的毫秒数内让当前正在执行的线程休眠(暂停方法) |
String getName() |
返回线程的名称 |
int getPriority() |
返回线程的优先级 |
void setPriority(int newPriority) |
更改线程的优先级 |
static Thread currentThread() |
返回当前正在执行的线程对象的引用 |
boolean isAlive() |
测试线程是否处于活动状态 |
void join() |
等待该线程终止 |
void interrupt() |
中断线程 |
void yield() |
暂停当前正在执行的线程对象,并执行其他线程 |