JAVA_Thread
1.Java多线程的两种实现方法
(1)继承Thread父类:
a.写一个Thread类的子类
b.重写run方法
c.实例化一个该子类的对象
d.通过start方法来启动线程
(2)实现Runnable接口
a.写一个类实现Runnale接口
b.实现Runable接口的run方法
c.用该类实例化对象
d.用该对象实例化一个Thread对象
2.Thread常用方法
a.启动线程: th.start();
b.是否活动: th.isAlive();
c.线程休眠: th.sleep(100);
d.暂停执行: th.yield();
d.等待结束: th.join();
e.设置优先级: th.setPrority(Thread.MIN_PRIORITY)