实现方法
- 继承thread,重写run方法
1.1 继承thread
1.2 new对象
1.3 start - 实现runnable,重写run方法
2.1 实现接口
2.2 new对象
2.3 丢到thread里
2.4 start
type | content |
---|---|
synchronized | 加锁,在方法或者代码块上加锁 |
voliate | |
sleep | 线程休息 |
wait | 线程等待,类似暂停键 |
notify | 线程唤起,类似开始键 |
join | 加入线程,一个线程在运行时,另一个线程执行join加入;主线程等待子线程结束 |
yeild | 线程让步,一个线程让步后,让另外一个线程运行 |
https://segmentfault.com/a/1190000014428190