随笔分类 -  java

摘要:1.安装插件 备注:freemarker、springboot、propertiesEdit、OpenExplorer、Enhanced Class Decompiler都是自带的,无需安装。 2.ctrl+space换成alt+/ 3.设置maven 4.设置字体 5.设置注释 --新建类 --后 阅读全文
posted @ 2019-02-25 17:53 遥远2 阅读(228) 评论(0) 推荐(0)
摘要:1、freemarker 2、svn 3、阿里规范 4、OpenExplorer 5、jetty 6、properties-edit 7、sts 8、MyBatipse 9、Enhanced Class Decompiler 附录eclipse各版本: https://www.eclipse.org 阅读全文
posted @ 2019-02-20 09:54 遥远2 阅读(239) 评论(0) 推荐(0)
摘要:阿里规范要求的标准做法2 hutool创建ThreadFactory 输出: 15:11:16.098 test-pool-0 15:11:16.098 test-pool-1 15:11:16.098 test-pool-2 15:11:18.101 test-pool-1 15:11:18.10 阅读全文
posted @ 2019-02-13 15:16 遥远2 阅读(436) 评论(0) 推荐(0)
摘要:创建线程池,阿里规范插件要求: 1、采用ThreadPoolExecutor,而不是Executors 2、采用自定义ThreadFactory,便于为线程命名。 输出: ThreadTest1ThreadTest2ThreadTest32019-02-13 14:21:34.263 [] INFO 阅读全文
posted @ 2019-02-13 14:27 遥远2 阅读(346) 评论(0) 推荐(0)
摘要:3种实现:thread、runnable、callable 1、thread 2、runnable 3、callable 阅读全文
posted @ 2019-02-01 10:09 遥远2 阅读(126) 评论(0) 推荐(0)
摘要:输出: 09:54:09.657 [main] INFO c.e.callable.MyTest:16 - 1000000 输出类、方法、行号时,不用使用:%C,%M,%L,官方不推荐使用,有时打印不出来,而是使用%logger 阅读全文
posted @ 2019-02-01 09:59 遥远2 阅读(127) 评论(0) 推荐(0)
摘要:需求:收到银行异步通知,要在2秒内将结果返回银行,同时还要根据银行返回的交易状态更新数据库订单状态和其他业务。 采用disruptor,其实最好使用独立MQ产品。本次用的是disruptor,遇到了一些问题,本文说下disruptor的问题排查。 问题1、消费者不在接收队列消息。 原因:handle 阅读全文
posted @ 2019-01-31 16:54 遥远2 阅读(1661) 评论(0) 推荐(0)
摘要:log4j2.xml 测试输出 解决: 把以上红色字体:<AppenderRef ref="CONSOLE"/>,去掉即可。 原因: logger继承Root,而Root中已经写了<AppenderRef ref="CONSOLE"/>,如果在logger中再次写,则重复打印。 阅读全文
posted @ 2019-01-25 10:28 遥远2 阅读(916) 评论(0) 推荐(0)
摘要:问题: Eclipse里,阿里编码规约插件扫描代码出现,但是idea却没有。 解决: 将以上注解改成 原因: 1、@Data包含了@Getter @Setter @RequiredArgsConstructor @ToString @EqualsAndHashCode。 @RequiredArgsC 阅读全文
posted @ 2019-01-23 14:25 遥远2 阅读(812) 评论(0) 推荐(0)
摘要:例子1(scheduleAtFixedRate):延迟2秒后,每隔3秒执行1次 运行结果: 例子2(scheduleWithFixedDelay):延迟5秒后,每个任务执行完后延迟3秒在执行1次 运行结果: 本来是每隔3秒执行的,但是,由于某个任务处理时间过长,导致延后。本例是延后1秒,即4秒。 总 阅读全文
posted @ 2018-09-07 18:54 遥远2 阅读(781) 评论(0) 推荐(0)
摘要:例子1:延迟3秒后,只执行1次 运行结果: 调用的ThreadPoolExecutor: corePoolSize=5,maximumPoolSize=Integer.MAX_VALUE keepAliveTime=0纳秒 allowCoreThreadTimeout=false(默认) 采用延迟队 阅读全文
posted @ 2018-09-07 18:50 遥远2 阅读(1744) 评论(0) 推荐(0)
摘要:例子: 运行结果: 调用的调用的ThreadPoolExecutor: corePoolSize=0,maximumPoolSize=Integer.MAX_VALUE keepAliveTime=60秒 allowCoreThreadTimeout=false(默认) 因此, 核心线程数为0 每来 阅读全文
posted @ 2018-09-07 18:37 遥远2 阅读(1100) 评论(0) 推荐(0)
摘要:例子: 调用的ThreadPoolExecutor: corePoolSize=maximumPoolSize=5 keepAliveTime=0 allowCoreThreadTimeout=false(默认) 因此, 线程池中的线程数永远是5,永久存活。 对于新任务,当队列未满时,插入队列;当队 阅读全文
posted @ 2018-09-07 18:27 遥远2 阅读(2105) 评论(0) 推荐(1)
摘要:使用默认的 thread factory创建ThreadPoolExecutor实例 例子: 参数解释: corePoolSize:线程池中的核心线程数 maximumPoolSize:线程池中的最大线程数 keepAliveTime: 当allowCoreThreadTimeout=false(默 阅读全文
posted @ 2018-09-07 17:50 遥远2 阅读(119) 评论(0) 推荐(0)