- 博客(22)
- 收藏
- 关注
转载 基于session的登录权限控制及redis缓存引入
一、容器端session 1、当浏览器第一次访问服务器时,使用request.getSession()方法,服务器会创建一个Session对象和具有JSESSIONID键值的cookie,成功返回后浏览器会得到一个包含sessionId的Cookie。 2、浏览器再次访问服务器时,会携带具有JSESSIONID属性的cookie到服务器,再次使用request.getSess...
2018-06-06 00:14:00
396
转载 CountDownLatch 和 CyclicBarrier
一、CountDownLatch 其实要完成这种某个线程等待其他线程结果才能开始任务的业务,直接在需要准备的线程中join()依赖的线程就能完成要求,但是在博客的上一篇《三个线程顺序输出》中也说到过,join的线程返回,必须是子线程已经结束。而CountDownLatch提供了更灵活的方案,可在子线程完成好其他线程依赖的工作后调用countDown()方法主动减少计数,同时继续做线...
2018-06-03 22:51:00
118
转载 join()介绍及三个线程顺序输出实现
一、join介绍 Thead.join()函数在使用后,会挂起调用线程,直到被调用线程结束执行,调用线程才会继续执行。源码中调用join后,方法会一直检测要join()的线程是否存活(isAlive()方法),直到线程执行完成后,调用线程的this.notifyAll()方法,才会回到刚刚挂起的主程序。基本操作如下:public class Worker extends T...
2018-06-03 18:47:00
294
转载 BigDecimal 和 BigInteger 介绍
一、BigDecimal 熟悉浮点记数的朋友知道,用二进制表示十进制小数是存在误差的,在涉及到金钱等其他对小数精度要求高的场景下Java提供了BigDecimal类,以满足需要。 先看构造函数: public static void main(String[] args) { BigDecimal aNum = new BigDecimal(...
2018-06-03 18:00:00
125
转载 62. Unique Paths
62. Unique PathsA robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is...
2018-06-02 18:35:00
108
转载 678. Valid Parenthesis String
678. Valid Parenthesis StringGiven a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a stri...
2018-06-02 17:33:00
125
转载 171. Excel Sheet Column Number
171.Excel Sheet Column NumberGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... ...
2018-06-01 22:36:00
88
转载 172. Factorial Trailing Zeroes
172.Factorial Trailing ZeroesGiven an integern, return the number of trailing zeroes inn!.Example 1:Input: 3Output: 0Explanation:3! = 6, no trailing zero.Example 2:Input: 5Out...
2018-06-01 22:18:00
91
转载 数据库事务
一、事务的特性 ACID: 1、原子性(Atomicity) 事务是最小的不可分割单元。只有做完和回滚,没有中间状态。 2、一致性(Consistency) 数据库总是从一个一致的状态转换到另一个一致的状态。这个有些容易和隔离性弄混淆,其实二者有内在的因果关系。正是隔离性的级别,造成了一致性的差异,这里的一致性可以简单理解为在某个时间...
2018-05-31 01:06:00
60
转载 75. Sort Colors
75. Sort ColorsGiven an array withnobjects colored red, white or blue, sort themin-placeso that objects of the same color are adjacent, with the colors in the order red, white and blue.He...
2018-05-30 21:36:00
157
转载 55. Jump Game
55.Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that posi...
2018-05-27 23:35:00
94
转载 17. Letter Combinations of a Phone Number
17.Letter Combinations of a Phone NumberGiven a string containing digits from2-9inclusive, return all possible letter combinations that the number could represent.A mapping of digit to let...
2018-05-27 22:23:00
121
转载 5. Longest Palindromic Substring
Longest Palindromic SubstringGiven a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab"...
2018-05-25 18:55:00
183
转载 3. Longest Substring Without Repeating Characters
3.Longest Substring Without Repeating CharactersGiven a string, find the length of thelongest substringwithout repeating characters.Examples:Given"abcabcbb", the answer i...
2018-05-24 22:16:00
83
转载 73. Set Matrix Zeroes
73.Set Matrix ZeroesGiven amxnmatrix, if an element is 0, set its entire row and column to 0. Do itin-place.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ ...
2018-05-23 00:01:00
84
转载 49. Group Anagrams
49. Group AnagramsGiven an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat","tan"], ...
2018-05-21 23:48:00
77
转载 Python安装,简单爬虫开发环境起步
1.python-3.6.1.exe 1)安装时选择add to path 和 for all user 2)安装32位是出于兼容更多开发库的考虑2.验证 1)cmd python 2)from urllib.request import urlopen 无报错说明安装成功3.安装beautifulSoup4 cmd: pip install beauti...
2018-05-20 16:26:00
91
转载 Java环境变量配置
1.官网安装包jdk-8u77-windows-x64.exe2.环境变量 1)JAVA_HOME D:\Program Files\Java\jdk1.6.0 2) Path %JAVA_HOME%\bin; 3)classpath ;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar3.测试 cm...
2018-05-20 16:20:00
93
转载 Java内存模型和GC基础
1、java内存模型 1.1、运行时数据区分为五大块: 1、程序计数器,应对中断、时间片执行,记录当前执行到的字节码位置,以便后续继续执行; 2、虚拟机栈,即平时所谓的栈区,存储局部变量、动态链接、方法出口等; 3、本地方法栈,为native方法服务,基本同虚拟机栈,在Hotspot中虚拟机栈和本地方法栈被合并; 4、方法区,存储类加载信息、...
2018-05-20 16:14:00
89
转载 单列模式对比
单例模式。构造函数是私有的,通过一个共有的成员函数还调用这个构造函数,在多线程环境下,还需要对这个成员函数进行加锁。下面是4种单例的创建方式,最安全也最好的是第4种,使用内部类的方式。1、懒汉式单例,线程不安全的// 1、懒汉式单例,线程不安全的 public class Singleton { private static Singleto...
2018-05-20 16:10:00
99
转载 编码格式坑之UTF-8
数据库创建后执行脚本,出错,很明显的编码问题。要说这个之前在用Oracle的时候也遇到过,本地字符集是utf-8,数据库要用ascii,但是这次再三检查,数据库和执行脚本都是utf-8啊。 由于问题已经定位,一翻搜索后还是能很快找到结果的,问题在于下面这句:create database test_db default character set utf8 collat...
2018-05-20 15:43:00
127
转载 15. 3Sum
15. 3SumGiven an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution se...
2018-05-20 15:16:00
151
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人