Java之Java基础
Java之Java基础
搬砖的孟达
我魔鬼筋肉人并非浪得虚名...
展开
-
一道Java基础题
public static void main(String[] args) { int a = Integer.MAX_VALUE -100; int b = Integer.MAX_VALUE; int count = 0; for (int i = a; i <= b ; i++) { count+...原创 2019-07-22 11:16:26 · 168 阅读 · 0 评论 -
HashMap源码分析 - HashMap的数据结构
HashMap源码分析HashMap的数据结构1.数组:2.链表:双向链表3.红黑树:二叉查找数源码中验证: /** * Holds cached entrySet(). Note that AbstractMap fields are used * for keySet() and values(). */ transient Node<K...原创 2019-10-28 22:54:24 · 162 阅读 · 0 评论 -
线程池讲解第二回
Java线程池的构造Java线程池的类关系图线程池的核心类 ThreadPoolExecutorThreadPoolExecutor: 所有的其他类和接口,都是围绕这个类提供的各自功能。AtomicInteger ctl:记录线程池状态和线程池数量,选择32位来记录,高3位用来记录线程状态,低29位记录线程数量。111:running,000:shutdown,001:stop,010:tidying,011:terminated。execute()方法:执行任务的方法。主要是通过判断原创 2021-07-22 16:32:24 · 113 阅读 · 0 评论 -
线程池讲解第一回
线程池讲解第一回 孟达手写线程池 街球王伟夜战叔弘简单的线程池实现public class ThreadPoolTrader implements Executor { private final AtomicInteger ctl = new AtomicInteger(); private volatile int corePoolSize; private volatile int maximumPoolSize; private final Blo原创 2021-07-21 17:43:31 · 68 阅读 · 0 评论 -
Java线程是如何启动 & Thread的状态转换
Java线程是如何启动的?简单来说:Java创建线程和启动调用本地方法start0()JVM中JVM_StartThread的创建和启动JVM中设置线程状态,等待被唤醒JVM根据不同的OS启动线程并且唤醒最后回调run()方法启动Java线程Thread的状态转换Java.lang.Thread.State枚举类中存在6个状态:new runnable blocked waiting timed_waiting terminatednew: "new Thread()"操作之后,原创 2021-07-16 14:58:49 · 157 阅读 · 0 评论 -
AQS与CAS了解
AQS你了解吗?AQS是AbstractQueuedSynchronizer简称,这是一个抽象类,提供了被子类覆盖的protected方法。在底层使用了CAS提供了乐观锁服务,如果冲突的时候,采用自旋方式进行重试,实现轻量级和高效的获取锁。通过AQS实现一个简单的Lock:在类中定义Sync内部类,Sync实现AbstractQueuedSynchronizer重写:tryAcquire,tryRelease,isHeldExclusively在tryAcquire中使用CAS,以预期值为0原创 2021-07-13 16:32:01 · 273 阅读 · 1 评论 -
解决 class path resource [xx] cannot be resolved to absolute file path because it does not reside
class path resource [xx] cannot be resolved to absolute file path because it does not reside发布线上之后出现的问题,查询资源发现是因为代码中直接调用getFIle()造成的问题。ClassPathResource classPathResource = new ClassPathResource("xxx/xxx.txt");File outFile = classPathResource.getFile();原创 2021-06-24 17:26:31 · 2860 阅读 · 2 评论 -
Java使用poi操作ppt
Java使用poi操作ppthttps://editor.csdn.net/md/?articleId=117926694上一篇中写了操作文本框和插入图片这一篇主要是如何在有模板的情况下如替换文本和修改表格替换表示符号文本1. 加载模板到对象中// 模板设置到项目中resources目录下ppt文件夹ClassPathResource classPathResource = new ClassPathResource("ppt/template.pptx");InputStream inpu原创 2021-06-24 17:08:54 · 1863 阅读 · 1 评论 -
Java使用poi导出ppt文件
导入poi相关依赖<!--导入依赖--> <dependencies> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </depe原创 2021-06-15 15:57:33 · 2156 阅读 · 5 评论 -
SpringBoot中服务器加载resource中文件
SpringBoot中加载resource文件下的文下午孙大俊她们的项目中出现了一个问题;大俊写的好的程序在本地写跑的好好的,但是打包之后部署到服务器就会出现问题。。。经过我的研究和网站上各种查找,最后解决了。。。加载resource下的文件使用 方法1: File resourceFile = ResourceUtils.getFile("classpath:xxx.txt"); 方...原创 2019-08-16 22:44:48 · 868 阅读 · 0 评论 -
Nginx的两个问题
Nginx的两个问题昨天我们村的村花孙大俊,出现了两个Nginx的错误。让我帮着解决,但是我是个菜鸟…没能给我的大俊把问题解决了,心情直接 down low 了。第一个问题nginx反向代理,使用域名+服务地址上传60m文件上传不成功,但是使用ip地址+服务地址就可以上传成功。解决问题:将nginx的配置client_max_body_size 200m第二个问题nginx反向代理...原创 2019-07-11 14:20:01 · 230 阅读 · 0 评论 -
java基础知识总结之String
java基础知识总结之String认识String: 位于java.lang包下;从概念上讲,Java字符串就是Unicode字符串的字符序列。String重点: String的理解的重点就是对字符串是一个常量的理解;字符串是存放在常量池中。这里也是java中关于字符串常见的面试的关键点。Java中的String常见的几道面试题: 首先要明确的是Java中“==”都是比较的引用地...原创 2019-06-30 23:21:37 · 200 阅读 · 0 评论 -
Java中LinkeLlist源码阅读
面试题: 取链表中倒数第k的值:public void getLinkedListObj(LinkedList linkedList,int k){ if(linkedList.isEmpty()){ System.out.print("集合为空..."); return; } int size = linkedList.size(); ...原创 2018-06-22 14:20:51 · 186 阅读 · 0 评论 -
java线程学习之线程的开启
线程开启(and命名): // 线程1 Thread myThread = new Thread("threadNo1"){ public void run(){ System.out.println("线程No1"); } }; //线程2 MyThread mt = new MyThread(); ...原创 2018-04-20 12:22:11 · 237 阅读 · 1 评论 -
jfinal配置Quartz
在JfinalConfig中添加QuartzPlugin (导包为:import cn.dreampie.quartz.QuartzPlugin;)//定时任务插件QuartzPlugin quartzPlugin = new QuartzPlugin();quartzPlugin.setJobs("quartzJob.properties");plugins.add(quartzPlu...原创 2018-04-23 17:23:34 · 464 阅读 · 0 评论 -
java定时操作
1.使用ScheduledExecutorService进行调度: (1)ScheduledExecutorService是通过线程池进行调度, (2)可以设置第一次执行任务的时间 (3)可以有效的控制时间周期2.使用实例代码:public static void main(String[] args) { Runnable runnable = new Runnable...原创 2018-04-16 12:20:49 · 359 阅读 · 0 评论 -
java 如何获取本地图片的宽度and高度
public static int[] getFileWidthAndHeight(String imageUrl){ File imageFile= new File(imageUrl); int[] arr = new int[2]; try { ImageInputStream imageInputStream = ImageIO.createImag...原创 2018-04-09 18:37:36 · 579 阅读 · 0 评论