一、线程的基本知识(Thread)

1. Thread.currentThread()方法:返回当前线程的信息

2. thread.interrupt()方法:停止线程,但只是在当前线程标记中断状态

3. thread.interrupted()方法:判断线程是否是中断状态,调用完之后会清除线程的中断状态

4. thread.setDaemon(true):设置守护线程,值得注意的是当进程中不存在非守护线程,则守护线程自动销毁,典型的守护线程为垃圾回收线程(GC)

5. 继承Thread类重写run方法和实现Runable接口为使用Thread的方法

 

posted @ 2020-09-21 21:24  迷迭香111  阅读(153)  评论(0)    收藏  举报