多线程

发布时间 2023-11-16 19:49:27作者: 白昼记忆

@

CPU 告诉你硬盘和网络到底有多慢

https://cizixs.com/2017/01/03/how-slow-is-disk-and-network/

java多线程有什么作用 好处?
https://cloud.tencent.com/developer/article/1841361
作用:
1、java多线程能够将各个任务分开执行,分开后的任务会同步进行
无需等待更多时间,效率也会更高
比如下载文件时如果使用java多线程的话,就能够同时下载多个文件。

2、java多线程能够分段执行
假如一个线程出现网络卡死的情况,那么多线程不会一直等待网络恢复正常,而是先执行其他的访问,如果操作超时会自动报错并释放相应线程

https://pdai.tech/md/interview/x-interview.html#32-并发关键字

https://www.liaoxuefeng.com/wiki/1252599548343744/1306580710588449

synchronized:
https://blog.csdn.net/m0_53474063/article/details/112389756

Java 对象的内存布局
https://www.51cto.com/article/713308.html

volatile
https://blog.csdn.net/didi1663478999/article/details/98523122
https://blog.csdn.net/xueping_wu/article/details/124541419

Java线程池 Executor

public interface eService extends Executor {
}

xxx implements eService {
}


类{
	class a implements Runnable{
		@Override
        public void run(){
        ...
        }
	}

	eService service;
	void cc(){
		service.execute(); // 会执行 上面的run()方法
	}

}