##什么是CAS

Compare-and-swap In computer science, compare-and-swap (CAS) is an atomic instruction used in multithreading to achieve synchronization 用来在多线程中获取同步的一个原子指令

##解决什么问题 比如比较常见的例子,计数的问题 public class IntegerTest { private static Integer count = 0; synchronized public static void increment() { count++; } }

• UML

• 类图

 Generalization ——— >
 Realization ____ >

Dependency(use a) —->

Association(has a) _____>

Aggregate(owns a) _____<> 空心

Composition(is part of) _____<> 实心

• code 真是一本好书呀

• 以下是一些常用的电路或者技术：

8位随机存储器基于继电器的实现，从继电器，真空管，再到集成电路的发展，摩尔定律的预言等等

# 计算机网络 Wiki

• 读书开始

• OSI模型，TCP/IP协议

• 20170509更新

• 网络层

• IP地址 IP地址的设计是层级设计的，比如物流配送，先是XX市，然后XX区，XX街道，XX小区

4大类的划分是按照ip地址二进制最高位几位划分的

00000000 XXXXXXXX XXXXXXXX XXXXXXXX 10000000 XXXXXXXX XXXXXXXX XXXXXXXX 11000000 XXXXXXXX XXXXXXXX XXXXXXXX 11100000 XXXXXXXX XXXXXXXX XXXXXXXX

A类的网络号是第一个字节

B类的网络号是前二个字节

C类的网络号是前三个字节

D类的网络号是前四个字节

• 子网掩码 二级划分不够灵活，使用子网掩码成功可以划分成三级

• ARP协议 功能，根据IP地址查找MAC地址，为啥要解析为MAC地址，因为链路层的frame(帧结构)使用的MAC硬件地址

• 路由选择协议

• IP多播

• VPN 和NAT 其中有个规定，RFC 1918 规定了一些专用地址

(1) 10.0.0.0 到 10.255.255.255

(2) 172.16.0.0. 到 172.31.255.255

(3) 192.168.0.0 到 192.168.255.255

(看到这里就有疑问了，我们基本上都是在局域网中，那么我们是怎么和其他公网服务器通信呢，

NAT使用是最广泛了，他对匮乏的IPV4地址资源绝对起了很大的缓解作用。

• 传输层

what？怎么理解面向报文和面向字节流，后面还有HTTP是面向字符的。

UDP是比较简单的，不需要连接，直接发送UDP报文，相比TCP真是简单快捷。

TCP是需要先进行连接的。其实连接不是物理通道上的连接，只是逻辑上的连接，著名的三次握手，四次挥手，

TCP的核心是如何实现可靠传输，注意是可靠，听起来很简单的词，实现起来可不简单，除了可靠还要效率，

socket编程了，不同的系统有自己的实现

unix：socket interface

windows：winSocket

• 总结一下

#Wiki

• What is regularExpression:
  A regular expression, regex or regexp[1] (sometimes called a rational expression)[2][3] is, in theoretical computer science and formal language theory,
a sequence of characters that define a search pattern.
Usually this pattern is then used by string searching algorithms for "find" or "find and replace" operations on strings.
public void static main () {
logger.info();
}

• 有什么作用
Regular expressions are used in search engines, search and replace dialogs of word processors
and text editors, in text processing utilities such as sed and AWK and in lexical analysis.
Many programming languages provide regex capabilities, built-in, or via libraries.

• Patterns

正则表达式组成结构，参看wiki，两部分:meta character or regular character

如何实现

 A regex processor translates a regular expression in the above syntax into an internal representation

which can be executed and matched against a string representing the text being searched in.

One possible approach is the Thompson's construction algorithm to construct a nondeterministic finite automaton (NFA),

which is then made deterministic and the resulting DFA is run on the target text string

to recognize substrings that match the regular expression. The picture shows the NFA scheme N(s*)

obtained from the regular expression s*, where s denotes a simpler regular expression in turn,

which has already been recursively translated to the NFA N(s).

• Standards 标准

 The IEEE POSIX standard has three sets of compliance: BRE (Basic Regular Expressions),[25] ERE (Extended Regular Expressions),

and SRE (Simple Regular Expressions). SRE is deprecated,[26] in favor of BRE,

as both provide backward compatibility. The subsection below covering the character classes applies to both BRE and ERE

1. linux 的grep命令有选项，-E 和 -G 就是选择哪个标准
2. perl正则已经演化为真正意义上的标准了，由于其丰富和强大的自动化表达式。 perl还提供了很多功能，比如懒加载，回溯，命名式捕获组和循环模式等，所有这些都是都对POSIX BRE/ERE强有力的补充 Java, JavaScript, Python等众多语言都是使用的perl like  java Perl regexes have become a de facto standard, having a rich and powerful set of atomic expressions.

Perl has no “basic” or “extended” levels, where the ( ) and { } may or may not have literal meanings.

They are always metacharacters, as they are in “extended” mode for POSIX. To get their literal meaning, you escape them.

Other metacharacters are known to be literal or symbolic based on context alone.

Perl offers much more functionality: “lazy” regexes, backtracking, named capture groups,

and recursive patterns, all of which are powerful additions to POSIX BRE/ERE. (See lazy matching below.)


详细的可以细读[Wiki](https://en.wikipedia.org/wiki/Regular_expression)

- java Pattern里的special constructs
看例子好像是对表达式匹配的值的二次限定，即对后面正则的二次限定范围
比如：
 java
we wanted to know if our input string contains the word “incident”
but that the word “theft” should not be found anywhere. We can use a negative look-ahead to
ensure that there are no occurrences.
“(?!.*theft).*incident.*”


http://www.ocpsoft.org/opensource/guide-to-regular-expressions-in-java-part-2/

    Look-ahead/behind constructs (non-capturing)
(?:X) 			X, as a non-capturing group
(?=X) 			X, via zero-width positive look-ahead
(?!X) 			X, via zero-width negative look-ahead
(?<=X) 			X, via zero-width positive look-behind
(?<!X) 			X, via zero-width negative look-behind
(?<X) 			X, as an independent, non-capturing group
So what does this all mean? What does a look-ahead really do for me? Say, for example,
we wanted to know if our input string contains the word “incident” but that the word “theft”
should not be found anywhere. We can use a negative look-ahead to ensure that there are no occurrences.
“(?!.*theft).*incident.*”
This expression exhibits the following behavior:
"There was a crime incident"			matches
"The incident involved a theft"			does not match
"The theft was a serious incident"		does not match


– java的量词

http://blog.csdn.net/carolzhang8406/article/details/6726546

贪婪量词：

惰性量词：

支配量词：


• What is a memory model, anyway?
• Do other languages, like C++, have a memory model?
• What is JSR 133 about?
• What is meant by reordering?
• What was wrong with the old memory model?
• What do you mean by incorrectly synchronized?
• What does synchronization do?
• How can final fields appear to change their values?
• How do final fields work under the new JMM?
• What does volatile do?
• Does the new memory model fix the “double-checked locking” problem?
• What if I’m writing a VM?
• Why should I care?

1. The Java Memory Model defines the behavior of volatile and synchronized, and, more importantly,

ensures that a correctly synchronized Java program runs correctly on all processor architectures;

1. The Java Memory Model was an ambitious undertaking;

it was the first time that a programming language specification

attempted to incorporate a memory model which could provide consistent semantics

for concurrency across a variety of architectures. Unfortunately,

defining a memory model which is both consistent and intuitive proved far more difficult than expected.

JSR 133 defines a new memory model for the Java language which fixes the flaws of the earlier memory model.

In order to do this, the semantics of final and volatile needed to change.

kiil -3 PID ，默认会出输出到catalina.out日志里

or 可以指定日志输出

1099: Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding

#问题分析

## 日志

jstat监控GC：

#调优 很详细 (http://www.importnew.com/22336.html)

#参考：

GC专家系列目录索引(推荐阅读) (https://segmentfault.com/a/1190000004369048)

[https://my.oschina.net/dabird/blog/691692] [http://blog.csdn.net/rachel_luo/article/details/8920596]

• 二叉树（英语：Binary tree）是每个节点最多有两个子树的树结构
• 与树不同，树的节点个数至少为1，而二叉树的节点个数可以为0；树中节点的最大度数没有限制，而二叉树节点的最大度数为2

#满二叉树

#完全二叉树

#二叉搜索树wiki

1. 任意节点的左子树不空，则左子树上所有结点的值均小于它的根结点的值；
2. 任意节点的右子树不空，则右子树上所有结点的值均大于它的根结点的值；
3. 任意节点的左、右子树也分别为二叉查找树；
4. 没有键值相等的节点。

#平衡二叉树 典型的代表有avl和红黑树 红黑树参照： https://github.com/julycoding/The-Art-Of-Programming-By-July/blob/master/ebook/zh/03.01.md