摘要:
/** * add 超过capacity会抛出异常 remove 队列为空会抛出异常 add和remove底层也是调用的offer和poll方法 * * offer 超过capacity会返回false poll 队列为空会返回null * * put 超过capacity会阻塞 take 队列为空 阅读全文
摘要:
public class MyLinkedList<E> { private Node first; private int size; public int size(){ return size; } @Override public String toString() { if(size == 阅读全文
摘要:
public class CompletableFuture3 { public static void main(String[] args) throws ExecutionException, InterruptedException { // testJoin(); testCompleta 阅读全文
摘要:
public class CompletableFuture2 { public static void main(String[] args) throws InterruptedException { // thenAcceptBoth(); // acceptEither(); // runA 阅读全文
摘要:
public class CompletableFutureTest { public static void main(String[] args) throws Exception { test5(); } /** * whenCompleteAsync指的是异步执行传入的BiConsumer 阅读全文
摘要:
controller层添加实体 html <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF 阅读全文
摘要:
Ctrl + N 按照类名搜索.java文件 Ctrl + Shift + N 按照文件名搜索文件,除了.java会被搜索出来,其他类型的文件也可被搜索出来 Ctrl + Shift + F 全局搜索 ,如果按了没效果则是快捷键与系统输入法冲突了,以搜狗输入法为例,将搜狗输入法的快捷键屏蔽 Ctrl 阅读全文
摘要:
idea热加载 第一步:添加依赖 spring-boot项目中引入如下依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId></dependen 阅读全文
摘要:
一句话概括,就是根据显示屏幕宽度的大小,自动的选用对应的类的样式 1、col是column简写:列 2、xs是maxsmall简写:超小, sm是small简写:小, md是medium简写:中等, lg是large简写:大; 3、-* 表示占列数,即占每行row分12列栅格系统比; 4、.col- 阅读全文
摘要:
1 秒杀流程 在上面的秒杀方法中: 避免发生超卖的解决方法是:在更新库存时,where条件后面加上stock>0 避免同一个用户秒杀两件商品的方法是:在秒杀结果表中设置唯一索引(用户ID和商品ID) 秒杀业务特点:(1)并发量大 (2)有时间限制,秒杀开始时间和秒杀结束时间 (3)商品库存有限制 不 阅读全文
摘要:
public class CompletableServiceTest { public static void main(String[] args) throws ExecutionException, InterruptedException { // test1(); // test2(); 阅读全文
摘要:
Futrue的缺点有(1)get方法会阻塞 ,(2)不支持注册回调方法 ,(3)不支持级联操作 CompletableFuture弥补了这些缺点 public class CompletableFutureTest { public static void main(String[] args) t 阅读全文
摘要:
ScheduledThreadPoolExecutor可以代替timer,timer的缺点是一个timer启动一个线程,如果任务数量很多,会创建很多线程,不推荐使用。 ScheduledThreadPoolExecutor他有个线程池管理线程管理所有任务,效率更高 public class Sche 阅读全文
摘要:
/** * CyclicBarrier 一组线程相互等待 */ public class Beer { public static void main(String[] args) { final int count = 5; final CyclicBarrier barrier = new Cy 阅读全文
摘要:
/** * 模拟铁人三项 */ public class PhaserTest { private static Random random = new Random(System.currentTimeMillis()); public static void main(String[] args 阅读全文