标签:setname tar 启动 new 形式 资源 imp ble name
线程的两种实现形式?
1. implement Runnable 接口
2.extends Thread
创建线程
Thread thread = new Thread (Runnable 对象或Thread 类的对象)
thread.start() 启动线程
如果要知道线程的名字
thread.setName("线程名");
线程池 executors
可缓存的线程池
固定的线程池
定时线程池
单线程化的线程池
线程池的好处:
1.限定线程的个数,不会导致线程过多导致系统运行缓慢或崩溃
2.线程池在开始不需要每次都去创建或销毁 : 1. 节约了资源 2. 响应速度更快
标签:setname tar 启动 new 形式 资源 imp ble name
原文地址:https://www.cnblogs.com/mm163/p/11087381.html