1.
实现Runnable接口
class run implements Runnable{
public void run(){
}
}
Thread th=new Thread();
th.start(new run());
继承Thread
class run extends Thread{
public void run(){
}
}
run th=new run();
th.start();
第一种用接口的方法比较好,使用比较灵活
2.
isAlive()线程是否还在执行或者阻塞
sleep()进入睡眠
getPriority()获得优先级数值
setPriority()设置
join()合并某线程
yield()让出CPU,当前线程进入等待调度
3.Theard d=new Theard([“线程名”]);