2026.3.25
面向对象的三大思想
封装:将事物的属性和行为封装为实体,对外隐藏实现,只暴露其接口
继承:对事物本质的抽象,实现了代码的复用
多态:一个接口或方法可以有多个实现,提高灵活性
guava cache
过期分为写入后过期和访问后过期
1 | LoadingCache<String, String> userCache = CacheBuilder.newBuilder() |
基于redisson实现的布隆过滤器
1 | public void redissonBloom() { |
http和https的区别
端口号,http是明文,https数据对称加密、密钥非对称加密
https的连接过程:client hello - server hello - 验证证书 - 交换密钥 - 生成对话密钥
xxxxxxxxxx public class Main { public static volatile AtomicInteger INTEGER = new AtomicInteger(0); public static void main(String[] args) throws InterruptedException { // 原子类实现自增操作 for (int i = 0; i < 10; i++) { new Thread(INTEGER::incrementAndGet).start(); } Thread.sleep(5); System.out.println(INTEGER.get()); }}java
osi模型
物理-数据链路-网络-传输-会话-表示-应用
比特流传输-封装成帧、差错检测(arp)-寻址(ip、osfp、rip)- 传输(tcp、udp) - 应用程序间通话 - 数据的解压缩、加解密 - 直接提供网络服务
synchronize的机制
分为代码块和方法锁,如果执行代码块会调用enter和exit方法,方法锁会设置方法的状态为有锁,等待隐式调用,monitor维护四个属性:oner、waitset、entryset、count,执行到enter方法后会尝试将oner设置为当前线程,失败则进入entryset,成功则count设置为1,执行exit指令后唤醒entryset,waitset中的线程通过wait方法进入,通过notify方法唤醒




