2019 年 02 月 - 7 文章

UnSafe的使用和分析 有更新!

  |   0 评论   |   2,764 浏览

最初在接触到UnSafe类是在看JAVA并发性编程源码的时候,在Atomic包的AtomicLong、AtomicInteger、AtomicReference等类中都定义了unsafe的变量。因为此前并没有接触过这个类,因此查阅了一些资料,看了UnSafe类的代码,在这里对相关知识做一个整理,以便日后方便查阅。 1. UnSafe 的作用 众所周知java无法直接访问操作系统的底层,只能通过JNI来访问native层。因此,UnSafe算是java留的一个后门,UnSafe类提供了硬件级别的原子操作,主要提供了以下功能: - 内存管理 通过UnSafe类可以分配内存,可以扩充内存,可以释放内存等 在UnSafe类中提供了三个native方法allocateMemory、reallocateMemory和freeMemory // 分配内存 public native long allocateMemory(long l); // 扩充内存 public native long reallocateMemory(long l,long ll); // 释放内存 pulic native....

Spring MVC的源码解析一 Root WebApplicationContext 有更新!

  |   0 评论   |   3,014 浏览

在了解Spring MVC 的源码之前了解下servletContext https://blog.csdn.net/qq_36371449/article/details/80314024 监听:当tomcat或者netty启动的时候,org.springframework.web.context.ContextLoaderListener就会监听到 <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 从而调用 ContextLoaderListener的#contextInitialized(ServletContextEvent event) 方法:初始化Root web应用程序上下文。 (一)对ContextLoaderListener进行分析 ContextLoaderListener ContextLoaderListener extends Context....

ECHO基本使用 有更新!

  |   0 评论   |   2,986 浏览

简单介绍了echo命令的基本使用方法与一些常见的使用场景;包括基本的常用的几个参数 -n,-e的介绍使用,同时对参数的是否使用括号的区别与最佳实践进行了说明与实践;