- 博客(47)
- 资源 (2)
- 收藏
- 关注
原创 Java中volatile关键字
当多个线程进行操作共享数据(内存中)时,线程先读取内存中的数据,并各自缓存一份,然后对缓存数据进行修改,最后再写入到内存中,但有时候由于程序执行速度快(如while操作),导致没有及时去内存中读取新的数据,而此时有可能其它线程已经修改了共享的数据,这就可能导致程序执行出现不可想象的偏差,而volatile就是为了防止这种偏差出现。volatile可保证内存中的数据可见(就是每次都会去读内存中的数...
2019-07-10 00:07:57
205
原创 Java运算符>>与>>>区别详解
1、>>带符号右移(相当于除以2)。正数右移高位补0,负数右移高位补1。比如:4 >> 1,4的原码为0000 0000 0000 0000 0000 0000 0000 0100,右移一位后为0000 0000 0000 0000 0000 0000 0000 0010,转成十进制为2。-4 >> 1,-4的原码为1000 0000 0000 0000 ...
2019-03-15 14:47:50
2964
6
原创 SpringBoot2.x中Actuator的health响应信息不完整的解决方法
使用SpringBoot2.x中的Actuator时,我们通过浏览器发送health请求来查看健康信息,但是详细的健康信息是默认不显示的,例如:{ status: "UP"}如果我们想要查看详细信息,应在application.properties做如下配置:management.endpoint.health.show-details=always这个属性有3个值可选:never...
2018-12-23 22:52:00
4494
1
原创 SpringBoot 2.x使用缓存注解时,自定义RedisTemplate序列化对象为json无效的原因,及解决办法
首先我们要知道,当使用缓存注解时,RedisCacheManager帮我们创建RedisCache来作为缓存组件,RedisCache通过操作redis缓存数据。而在springboot 1.5.x,RedisCache又是通过RedisTemplate来操作redis缓存数据。而在srpingboot 2.x,RedisCache没有使用到RedisTemplate。下面来看srpingboo...
2018-12-06 14:58:58
4853
3
原创 源码分析SpringBoot2.x 静态资源被拦截器拦截的原因
1、静态资源路径的注册先来看WebMvc的自动配置类:WebMvcAutoConfiguration,它里面有个内部类:WebMvcAutoConfigurationAdapter,其中有个方法addResourceHandlers,实现如下@Configuration//引入EnableWebMvcConfiguration对象到容器中@Import(EnableWebMvcConfig...
2018-11-27 22:50:51
1715
原创 《算法导论》红黑树详解(二):Java实现Demo
《算法导论》红黑树详解(一):概念使用Java简单地实现红黑树代码如下:/** * 红黑树实现demo */public class RedBlackTree<Key extends Comparable<Key>> { private static final boolean RED = false; private static fin...
2018-11-03 00:45:31
393
原创 《算法导论》红黑树详解(一):概念
在学习红黑树之前,读者应先掌握二叉查找树的相关知识。学习红黑树或者二叉查找树,推荐大家看《算法导论》。《算法导论》原书第3版 高清PDF 带详细书签目录下载 密码:acis一、红黑树介绍 红黑树是每个结点都带有颜色属性的二叉查找树,颜色为红色或黑色。通过对任意一条从根到叶子的简单路径上各个结点的颜色进行约束,红黑树确保没有一条路径比其他路径长2倍,因而是近似于平衡的。 树中每个结点包含5...
2018-10-30 23:14:32
1421
原创 阶乘n!的结尾后面有多少个零
LeetCode - 阶乘后的零思路:我们将 n! 进行质因数分解,使它由质数相乘得来,即 n!=2x×3y×5z×7w×...n!=2^x \times 3^y \times 5^z \times 7^w \times ...n!=2x×3y×5z×7w×...,这样10只能由2×52 \times 52×5产生,而2的个数要比5的个数多,因为从1开始数,每连续两个自然数就有一个2的倍数,可以...
2018-10-21 13:27:05
1150
1
原创 ajax请求遇到session过期又被过滤器拦截的解决方案
最近写项目碰到一个比较棘手的问题,就是当用户session过期时,访问html页面,浏览器会加载缓存里的html页面,导致没有被过滤器拦截,而里面的ajax请求却被过滤器拦截了,导致页面什么都没有显示。 在网上找了一些解决方案,感觉都比较复杂,于是自己想了一个解决方案,也拿出来给大家参考一下。在过滤器里判断是否为ajax请求,ajax请求的请求头里有ajax特有的参数X-Requested-...
2018-08-05 19:43:18
1074
转载 如何在Listener(监听器)中使用spring容器管理的bean
本文转自:http://www.cnblogs.com/fjdingsd/p/5731982.html正好以前项目中碰到这个问题,现在网上偶然又看到这个问题的博文,那就转一下吧。原文:http://blog.lifw.org/post/46428852 感谢作者另外补充下:在web Server容器中,无论是Servlet,Filter,还是Listener都不是Spring容器管理的...
2018-07-22 22:19:34
507
原创 打开elementary os的dock样式设置
在elementary os的默认的dock的边缘可以单击右键打开dock的样式设置,但更换样式后,这种方式可能就行不通了。后来通过google,我找到一种更好的方式: 1、按住ctrl键。 2、鼠标悬停在dock上,右键。 3、选择“首选项”。 然后,你就可以设置你的dock样式了。...
2018-03-14 22:56:31
2720
原创 python中pymysql的executemany使用总结
在使用pymysql的executemany方法时,需要注意的几个问题1、在写sql语句时,不管字段为什么类型,占位符统一使用%s,且不能加上引号。例如sql="insert into tablename (id,name) values (%s,%s)"2、添加的数据的格式必须为list[tuple(),tuple(),tuple()]或者tuple(tuple(),tuple(...
2018-03-01 00:13:30
28449
5
原创 利用MySQL实现一个类似美团外卖的外卖订单的数据库管理系统
利用MySQL实现一个类似美团外卖的外卖订单的数据库管理系统本文的重点在于MySQL触发器的应用1、数据库需求分析 1)数据库实体:客户、商家、商品、订单。 2)一个客户对应多个订单。 3)一个商家对应多种商品和多个订单。 4)一个订单对应一种商品。2、系统功能分析 1)客户注册:客户通过添加必要的信息到数据库来完成注册。
2018-01-28 21:20:04
36648
21
原创 ubuntu使用SSH通过Termux登录Android设备
termux是一个强大的linux终端模拟器 在手机端通过ssh连接linux比较容易,直接用密码登录就好。 而想要linux连接手机就需要用密钥登录。保证电脑和手机在同一网络下 以192.168.1.101为电脑ip地址 以192.168.1.109为手机ip地址ubuntu使用ssh通过密钥登录手机安装openssh手机下载安装好termux后,打开te
2017-10-26 00:27:04
13151
原创 HDU-2091 空心三角形
把一个字符三角形掏空,就能节省材料成本,减轻重量,但关键是为了追求另一种视觉效果。在设计的过程中,需要给出各种花纹的材料和大小尺寸的三角形样板,通过电脑临时做出来,以便看看效果。
2016-11-18 21:16:14
280
原创 HDU-1003 Max Sum
Given a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 =
2016-11-16 21:01:06
233
原创 CodeForces-651A. Joysticks
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect char
2016-08-25 15:29:14
251
原创 CodeForces-709A. Juicer
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, …, an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so
2016-08-25 15:09:56
508
原创 CodeForces-710B. Optimal Point on a Line
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.Input The first line contains integer n (1 ≤ n ≤ 3·105) — the number
2016-08-24 22:01:11
568
原创 CodeForces-710A. King Moves
The only king stands on the standard chess board. You are given his position in format “cd”, where c is the column from ‘a’ to ‘h’ and d is the row from ‘1’ to ‘8’. Find the number of moves permitted f
2016-08-24 12:28:44
365
原创 CodeForces-707A. Brain's Photos
Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.As
2016-08-21 21:03:39
320
原创 CodeForces-706B. Interesting drink
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink “Beecola”, which can be bought in n different shops in the city.
2016-08-21 20:09:03
370
原创 CodeForces-706A.Beru-taxi
Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi i
2016-08-20 18:56:15
590
原创 计蒜客-泥塑课
小米是一个幼儿园老师,每学期的泥塑课上,她都会给每个学生发不超过250立方厘米的等量橡皮泥,教大家做泥塑。在上课过程中,她发现每个班都恰好有一个小朋友会去抢另一个小朋友的橡皮泥,于是她决定,在正式开始做泥塑前,让大家把手里的橡皮泥都捏成一个立方体,并且测量手里捏好的橡皮泥的长、宽和高。这样,她就可以知道谁被谁抢了橡皮泥了。小米老师在不同的学期可能会带一个班或者同时带多个班,因此输入数据可能有一组或者
2016-08-20 18:09:23
302
原创 HDU-4135-Co-prime
Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relatively prime
2016-08-09 22:46:59
232
原创 CodeForces-622A.Infinite Sequence
Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5…. The sequence is built in the following way: at first the number 1 is written out, then the numbers from 1 to 2,
2016-08-09 22:28:25
245
原创 HDU-2689-Sort it
You want to processe a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted in ascending order. Then how many times it need.
2016-08-08 23:25:38
241
原创 CodeForces-630F.Selection of Personnel
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. No
2016-08-08 23:15:21
309
原创 CodeForces-688C.NP-Hard Problem
Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.Suppose the graph G is given. Subset A of its vertices is called a vert
2016-08-08 23:03:07
438
原创 CodeForces-689C.Mike and Chocolate Thieves
Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible!
2016-08-07 22:33:07
344
2
原创 CodeForces-493A.Vasya and Football
Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatica
2016-08-06 22:38:04
303
原创 CodeForces-681B.Economy Game
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become
2016-08-06 22:27:57
256
原创 HDU-1700 Points on Cycle
There is a cycle with its center on the origin. Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each
2016-08-05 22:45:33
271
原创 Codeforces-545D. Queue
Little girl Susie went shopping with her mom and she wondered how to improve service quality.
2016-08-04 22:13:59
1396
原创 POJ-2251 Dungeon Master
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock.
2016-08-04 21:22:44
167
原创 HDU-5464-Clarke and problem
Clarke is a patient with multiple personality disorder. One day, Clarke turned into a student and read a book. Suddenly, a difficult problem appears: You are given a sequence of
2016-07-25 22:16:59
184
原创 CodeForces-546D.Soldier and Number Game
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier.
2016-07-24 22:44:46
314
原创 Codeforces-B.Soldier and Badges - Codeforces Round #304 (Div. 2)
B. Soldier and Badges time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard
2016-07-23 23:20:01
290
原创 CodeForces-610B-Vika and Squares
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper
2016-07-22 23:31:50
314
原创 CodeForces-660A-Co-prime Array
You are given an array of n elements, you must make it a co-prime array in as few moves as possible.In each move you can insert any positive integral number you want not greater than 109 in any place i
2016-07-22 22:54:23
354
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人