- 博客(148)
- 收藏
- 关注
原创 nacos server startup failure with cluster
将 startup.cmd 的 mode =“cluster” 改为 mode=“standalone”
2021-04-11 21:52:10
185
原创 Redis02-String通用API
String usageSETReturn ValueSyntaxExampleOptionsGETExampleGETRANGEExampleGETSETExampleGETBITSyntaxExampleMGETSyntaxExampleSETEXExampleSETNXExampleSETRANGESyntaxExampleSETRedis SET command is used to set some string value in Redis key.Return ValueSimple
2021-04-08 17:46:09
181
原创 二分查找
binary search如何识别二分查找?成功的二分查找的3个部分二分查找的三个模板模板1如何识别二分查找?二分查找是一种在每次比较之后将查找空间一分为二的算法。每次需要查找集合中的索引或元素时,都应该考虑二分查找。如果集合是无序的,我们可以总是在应用二分查找之前先对其进行排序。成功的二分查找的3个部分预处理 — 如果集合未排序,则进行排序。二分查找 — 使用循环或递归在每次比较后将查找空间分为两半。后处理 — 在剩余空间中确定可行的候选者。二分查找的三个模板模板1是二分查找的最基础
2021-04-08 16:57:08
238
原创 链表中双指针问题模板
// Initialize slow & fast pointersListNode slow = head;ListNode fast = head;/** * Change this condition to fit specific problem. * Attention: remember to avoid null-pointer error **/while (slow != null && fast != null && fast.nex
2021-04-08 14:25:00
135
原创 redis通用API
DEL 删除keyRedis DEL command is used to delete the existing key in Redis.Syntax 语法redis 127.0.0.1:6379> DEL KEY_NAME Example 例子redis 127.0.0.1:6379> SET tutorialspoint redis OKredis 127.0.0.1:6379> DEL tutorialspoint (integer) 1DUMP 序列化k
2021-04-07 18:01:29
101
原创 redis历险-01
5种基础数据结构string、list、hash、set、zsetString字符串结构使用非常广泛,一个常见的用途就是缓存用户信息。我们将用户信息结构体使用JSON序列化成字符串,然后将序列化后的字符串放进Redis来缓存。Redis的字符串是动态字符串,是可以修改的字符串,内部结构的实现类似于Java 的 Array List,采用预分配冗余空间的方式来减少内存的频繁分配。当字符串长度小于1MB时,扩容都是加倍现有的空间。如果字符串长度超过1MB,扩容时一次只会多扩1MB的空间。需要注意的是字
2021-04-07 17:26:21
117
原创 Floyd判圈算法
Floyd判圈算法又称龟兔赛跑算法(Tortoise and Hare Algorithm),是一个可以在有限状态机、迭代函数或者链表上判断是否存在环,求出该环的起点与长度的算法。如果有限状态机、迭代函数或者链表上存在环,那么在某个环上以不同速度前进的2个指针必定会在某个时刻相遇。同时显然地,如果从同一个起点(即使这个起点不在某个环上)同时开始以不同速度前进的2个指针最终相遇,那么可以判定存在一个环,且可以求出2者相遇处所在的环的起点与长度。以 leetcode 141. 环形链表 为例:https:/
2021-04-01 17:10:15
120
原创 Centos 7上安装docker及设置自启动
Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository. sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repoInsta.
2021-03-28 11:33:46
182
原创 动态规划专题
什么是动态规划?动态规划(Dynamic programming,简称DP)是一种在数学、管理科学、计算机科学、经济学和生物信息学中使用的,通过把原问题分解为相对简单的子问题的方式求解复杂问题的方法。动态规划不是某一种具体的算法,而是一种算法思想:若要解一个给定问题,我们需要解其不同部分(即子问题),再根据子问题的解得出原问题的解。应用这种算法思想解决问题的可行性,对子问题与原问题的关系,以及子问题之间的关系这两方面有一些要求,它们分别对应了最优子结构和重复子问题最优子结构最优子结构规定的是子问题
2021-03-24 17:37:00
115
原创 Java Expcetion
The try-with-resources StatementThe try-with-resources statement is a try stament that decalres one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each re
2021-03-23 17:59:40
251
原创 Write Professional Emails In English Week1
Perfessional Email BasicsMake sure you have an email address that is professional looking.You don’t have to include your full name but something that readers call easily verify as you should be find.Four basic of an email and how to write them.These fo
2021-03-22 22:50:26
602
原创 English2Day
A martial art = an art of self-defence without using weaponsTo find out about something = to learn new informationTo look up to someone = to respect and admireA sumo wrestler = a man who practices sumoA rank = The best wrestlers are in the top rankTo
2021-03-22 10:17:38
114
原创 Java8 New feature Lambda and Stream
LambdaBefore Java 8, filtering a list of persons by a specfic name, looked like this:public List<Person> getPersonWithName(List<Person> searchList, String firstName){ List<Person> foundPersons =new LinkedList<>(); for(Person p
2021-03-20 17:28:44
172
原创 java-basic-IO
BASIC IOI/O StreamsByte StreamsAlways Close StreamsCharacter StreamsCharacter Stream that Use Byte StreamsLine-Oriented I/OBuffered StreamsFlushing Buffered StreamsI/O StreamsAn I/O Stream represents an input source or an output destination. A stream can
2021-03-16 14:19:34
268
原创 java-basic-reflection
Class NameThe fully qualified class name(including package name) is obtained using the getName() like this:Class c = new String();// obtain Calss object.String className = c.getName(); //get Name including package name.if you want the class name witho
2021-03-15 12:04:32
1136
1
原创 java-basic knowledge
IntroductionThis essay is about JavaSE basic knowledge, while I’m prepare an interview for my next job opportunity. Hence, I wrote it to review for myself. All the content is short summary from 《Core Java》, Cay S. HorstmannFinal Instacne FieldsYou c
2021-03-13 17:39:07
135
原创 01-JAVA I/O - OverView
以下内容摘自:https://www.cnblogs.com/czwbig/p/10007201.htmlThe InputStream, OutputStream, Reader and WriterA program that needs to read data from some source needs an InputStream or a Reader. A program that needs to write data to some destination needs an Outp
2021-03-05 22:25:03
614
1
原创 10-JUC-Future and Callable
Future and Callable1. Runnable的缺陷2.Callable接口3. Future类4. 用法1: 线程池的submit方法返回Future对象5. 用法2: 用FutureTask来创建Future6.Future的注意点1. Runnable的缺陷不能返回一个返回值不能抛出异常2.Callable接口3. Future类4. 用法1: 线程池的submit方法返回Future对象/** * @Classname OneFuture * @Des
2021-03-01 21:53:30
122
原创 09-JUC-AQS
AQS1. 学习AQS的思路2. 为什么需要AQS3. AQS的作用4. AQS的重要性、地位5.AQS内部原理解析state控制线程抢锁和配合的FIFO队列期望协作工具类实现的获取/释放等重要方法6.应用实例、源码解析AQS的用法7.利用AQS实现一个简单的Latch1. 学习AQS的思路学习AQS的目的主要是想理解原理、提高技术、以及应对面试。2. 为什么需要AQS3. AQS的作用4. AQS的重要性、地位5.AQS内部原理解析state控制线程抢锁和配合的FIFO队
2021-03-01 15:44:13
136
原创 01-JVM-memory management
程序内存图Java虚拟机所管理的内存将会包括以下几个运行时数据区域线程共享区程序计数器由于Java虚拟机的多线程是通过线程轮流切换、分配处理器执行时间的方式来实现的,在任何一个确定的时刻,一个处理器(对于多核处理器来说是一个内核)都只会执行一条线程中的指令。因此,为了线程切换后能恢复到正确的执行位置,每条线程都需要有一个独立的程序计数器,各条线程之间计数器互不影响,独立存储,我们称这类内存区域为“线程私有”的内存Java虚拟机栈与程序计数器一样,Java虚拟机栈(Java Virtual Ma
2021-02-27 17:19:05
142
原创 08-JUC--并发流程
线程协作1.什么是控制并发流程2.CountDownLatchCountDownLatch的作用CountDownLatch的主要方法3.Semaphore主要方法介绍注意点4. Condition接口(条件对象)4.1 作用4.2 代码演示4.3 注意点5.CyclicBarrier1.什么是控制并发流程2.CountDownLatchCountDownLatch的作用CountDownLatch的主要方法/** * @Classname CountDownLatchDemo01
2021-02-26 16:36:19
104
原创 07-JUC--并发容器
并发容器概览ConcurrentHashMap;线程安全的HashMapCopyOnWriteArrayList:线程安全的ListBlockingQueue:这是一个接口,表示阻塞队列,非常适用于作为数据共享的通道。ConcurrentLinkedQueue:高效的非阻塞并发队列,使用链表实现。可以看做一个线程安全的LinkedListConcurrentSkipListMap:是一个Map,使用跳表的数据结构进行快速查找。集合类的历史Vector和Hashtable使用了synchron
2021-02-26 14:43:36
400
原创 基本遍历框架
数组void traverse(int[] arr) { for (int i = 0; i < arr.length; i++) { // 迭代访问 arr[i] }}单链表/* 基本的单链表节点 */class ListNode { int val; ListNode next;}void traverse(ListNode head) { for (ListNode p = head; p != null; p = p.n
2021-02-24 11:25:05
172
原创 01-Java-高性能编程
JVM运行时数据区方法区堆内存虚拟机栈程序计数器线程状态//线程示例代码public class Demo2 { public static Thread thread1; public static Demo2 obj; public static void main(String[] args) throws Exception { // 第一种状态切换 - 新建 -> 运行 -> 终止 System.out.println("#######第一种
2021-02-23 22:48:37
110
原创 05-Thread-java并发的其他基础知识
java中的线程安全问题共享资源,就是说该资源被多个线程所持有或者说多个线程都可以去访问该资源。线程安全问题是指当多个线程同时读写一个共享资源并且没有任何同步措施时,导致出现脏数据或者其他不可预见的结果的问题,脏数据(Dirty Read)是指源系统中的数据不在给定的范围内或对于实际业务毫无意义,或是数据格式非法,以及在源系统中存在不规范的编码和含糊的业务逻辑。java中共享变量的内存可见性问题Java内存模型规定,将所有的变量都存放在主内存中,当线程使用变量时,会把主内存里面的变量复制到自己的
2021-02-22 18:06:17
106
原创 04-Thread--java并发编程基础
Join方法/** * @Auther: match * @Date: 2021/2/22 12:21 * @Description: */public class JoinDemo { public static void main(String[] args) throws InterruptedException { Task1 task1 = new Task1(); Task2 task2 = new Task2(); Thre
2021-02-22 12:36:33
125
转载 03-Thread--中断机制
java中的中断机制阅读素材一:https://www.cnblogs.com/hapjin/p/5450779.html阅读素材二:https://www.ibm.com/developerworks/cn/java/j-jtp05236.html
2021-02-20 18:01:58
105
原创 02-Thread--基础线程机制
基础线程机制Executor守护线程 Daemowait , sleep , yieldExecutorExecutor 管理者线程的生命周期,提供了多个方法供我们使用。Executor的继承体系ThreadPoolExecutor实现的顶层接口是Executor,顶层接口Executor提供了一种思想:将任务提交和任务执行进行解耦。用户无需关注如何创建线程,如何调度线程来执行任务,用户只需提供Runnable对象,将任务的运行逻辑提交到执行器(Executor)中,由Executor框架完成线程
2021-02-20 17:34:12
187
原创 01Thread--使用线程的三种方式
使用线程的三种方式实现Runnable接口实现Callable接口继承Thread类实现 Runnable接口和 Callable接口相当于创建了一个可以在线程中运行的任务;创建任务后还需要Thread来驱动。Runnable需要实现接口中的 run(), 在方法内编写需要执行的任务/** * @Auther: match * @Date: 2021/2/20 16:25 * @Description: 演示Runnable接口的简单使用 */public class Runna
2021-02-20 16:42:17
118
原创 226. Invert Binary Tree
/** * @Auther: young * @Date: 2021/2/20 14:28 * @Description: Invert a binary tree. https://leetcode-cn.com/problems/invert-binary-tree/ */public class InvertTree { public TreeNode invertTree(TreeNode root) { if(root ==null){ .
2021-02-20 14:33:58
82
原创 110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the left and right subtrees of every node differ in height by no more than 1.来源:力扣(LeetCode)链接:https://leetcode
2021-02-20 14:17:28
80
原创 01-经济学基本常识-Never exactly equal
In the study of economics, all the interactions between supply, demand, and price are usually expressed by mathematical formulas. These formulas are often illustrated by points on a graph. Imagine a graph with price on one side and quantity (supply) on the
2021-02-19 23:08:28
411
原创 1450. Number of Students Doing Homework at a Given Time
Given two integer arrays startTime and endTime and given an integer queryTime.给两个整数数组和一个查询时间The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].第 i 个学生 在startTime[i]开始写作业,在endTime[i] 时 完成作业。Return th
2021-02-19 17:32:27
121
原创 07-JUC--Concurrent Container
并发容器 ConcurrentHashMap、CopyOnWriteArrayList、阻塞队列
2021-02-18 20:36:16
110
原创 06-JUC--Immutable
什么是不变性(Immutable)如果对象在被创建后,状态就不能被修改,那么它就是不可变的。具有不变性的对象一定是线程安全的,我们不需要对其采取任何额外的安全措施,也能保证线程安全。代码演示/** * @Classname Person * @Description 不可变对象,演示其他类无法修改这个对象。 * @Date 2021/2/18 17:12 * @Created by YoungLiu */public class Person { //加了final
2021-02-18 20:32:46
116
1
原创 05-JUC--CAS
什么是CAS? compare and swap参考博文: https://objcoding.com/2018/11/29/cas/CAS的等价代码/** * @Classname SimulatedCAS * @Description 模拟CAS操作,java实验CAS基本思想 * @Date 2021/2/18 15:13 * @Created by YoungLiu */public class TwoThreadsCompetition implements Runnable{
2021-02-18 15:36:09
120
原创 04-JUC--atomic
Atomic什么是原子类?有什么用?6类原子类纵览AtomicInteger常用方法代码演示1AtomicArray代码演示AtomicReference引用类型原子类代码演示把普通变量升级为具有原子功能代码演示什么是原子类?有什么用?不可分割一个操作是不可分割的,即使在多线程环境下也是不可分割的。在java中 java.util.concurrent.atomic 用于保证并发安全原子类的作用和锁类似,是为了保证并发情况下的线程安全。不过原子类相比于锁,有一定的优势。4.1 粒度更细:原子
2021-02-18 14:20:43
388
3
原创 02-mysql
数据库结构设计业务分析----》逻辑设计—》数据类型选型—》对象命名—》建库建表宽表模式把很多属性都放在一个表中;宽表模式存在的问题数据冗余:数据更新异常数据插入异常宽表模式有可能会造成一个表有会有很多非空约束或其他约束,而导致插入异常。4. 数据删除异常宽表模式的适用场景配合列存储的数据报表应用逻辑结构数据库设计范式第一范式第二范式第三范式3-14 End...
2021-02-18 11:18:49
160
1
原创 01-mysql
SQL VS NOSQLNoSQL - Not Only SQLSQL型数据库:Mysql,Oracle,SQLServer,PostGreSQLNO-SQL: HBase, MongoDB,Redis,Hadoop关系数据库的特点数据结构化存储在二维表种支持事务的原子性A,一致性C,隔离性I,持久性D; ACID支持使用SQL语言对存储在其中的数据进行操作关系型数据库的适用场景数据之间存在着一定关系,需要关联查询数据的场景。需要事务支持的业务场景需要使用SQL语言灵活操作数据的
2021-02-18 10:45:41
89
原创 03-JUC-Lock
Lock一级目录二级目录三级目录Lock接口为什么需要Lock?Lock的主要接口lock()代码演示t
2021-02-17 13:53:27
716
3
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人