Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
511 commits
Select commit Hold shift + click to select a range
d4270e9
Merge pull request #321 from jimmykwong/master
onlyliuxin Jun 19, 2017
6dcbab2
Merge pull request #378 from williamgx8/master
onlyliuxin Jun 19, 2017
22d667f
Merge pull request #393 from shuiqing05/master
onlyliuxin Jun 19, 2017
eeed6ad
Merge pull request #385 from lqhtmc/master
onlyliuxin Jun 19, 2017
6679cda
删除无用的代码
onlyliuxin Jun 19, 2017
0db2732
Merge remote-tracking branch 'refs/remotes/Greastate/master'
yangyangxu2016 Jun 19, 2017
4beaab4
重构邮件发送
yangyangxu2016 Jun 19, 2017
279d227
Merge pull request #318 from luoziyihao/master
onlyliuxin Jun 19, 2017
ae97f0e
02 ocp
Jun 19, 2017
c685383
重构后的代码
Allenzj Jun 19, 2017
a2afd81
homework
itdoudoutech Jun 19, 2017
e98a79a
Merge pull request #392 from gordonCN/master
onlyliuxin Jun 19, 2017
1ac0837
Merge pull request #384 from oceanbest/master
onlyliuxin Jun 19, 2017
db0b1a0
Merge pull request #298 from palmshe/master
onlyliuxin Jun 19, 2017
cd0dd12
Merge pull request #403 from yangyangxu2016/master
onlyliuxin Jun 19, 2017
5cddc7d
Merge pull request #313 from Horacehxw/master
onlyliuxin Jun 19, 2017
f17cc5d
Merge pull request #329 from kkc7316/master
onlyliuxin Jun 19, 2017
60e5567
Merge pull request #299 from 511739113/master
onlyliuxin Jun 19, 2017
cf8de7e
20170619_1509
orajavac Jun 19, 2017
b82b6b4
SRP 1.0-version
yuanfangblues Jun 19, 2017
27eef3d
Merge pull request #349 from mengmoli/master
onlyliuxin Jun 19, 2017
634ea6e
Merge pull request #404 from coderlmm/master
onlyliuxin Jun 19, 2017
f7021bd
Merge pull request #353 from Allenzj/master
onlyliuxin Jun 19, 2017
4909d08
Merge pull request #351 from PushWary/master
onlyliuxin Jun 19, 2017
7a45673
Merge pull request #348 from bvcalf/master
onlyliuxin Jun 19, 2017
b468fdf
delete season one
yyglider Jun 19, 2017
e92eb19
Update .gitignore
yuyingzhi828 Jun 19, 2017
5715b85
Merge pull request #342 from liushuojin/master
onlyliuxin Jun 19, 2017
a178e17
Merge pull request #335 from guoshenghui/master
onlyliuxin Jun 19, 2017
e4e013c
Merge pull request #323 from jiaxun1990/master
onlyliuxin Jun 19, 2017
d0b5a16
Merge pull request #314 from KevinSmile/master
onlyliuxin Jun 19, 2017
79df61f
Merge pull request #309 from yuyingzhi828/master
onlyliuxin Jun 19, 2017
720b0b0
Merge pull request #308 from orajavac/master
onlyliuxin Jun 19, 2017
62c6260
Merge pull request #307 from guozheng5/master
onlyliuxin Jun 19, 2017
55b3e74
Merge pull request #405 from yyglider/master
onlyliuxin Jun 19, 2017
ce5b7b3
Merge pull request #306 from mddonly/master
onlyliuxin Jun 19, 2017
002f38a
Merge pull request #300 from onlyLYJ/master
onlyliuxin Jun 19, 2017
cf87352
Merge pull request #296 from CheungChanDevCoder/master
onlyliuxin Jun 19, 2017
cc63c5f
Merge pull request #281 from littleshame/master
onlyliuxin Jun 19, 2017
b1ee84e
Merge pull request #280 from Maneng/master
onlyliuxin Jun 19, 2017
27b9fba
Merge pull request #277 from nightn/master
onlyliuxin Jun 19, 2017
9b47297
srp 349184132
yuanfangblues Jun 19, 2017
b81c9a1
remove code
onlyliuxin Jun 19, 2017
dd57883
ocp
Zering Jun 19, 2017
a380011
Merge pull request #1 from begin16119/boxin
yuanfangblues Jun 19, 2017
2a71732
广州-许洁:第二次ood作业ocp工程重构01
ilyle Jun 19, 2017
e48da5a
重构发送电子邮件
yangyangxu2016 Jun 19, 2017
e4b38c0
ood-srp-homeword
Jun 19, 2017
f6f23c0
srp
Jun 19, 2017
aab9cf8
Merge pull request #1 from onlyliuxin/master
Jun 19, 2017
8bdcd36
To refactor the email service of product promotion.
silencehe09 Jun 19, 2017
31199da
完成
Jun 19, 2017
50c5c06
删除第一季数据结构工程
ilyle Jun 19, 2017
ec98ab3
修改
Jun 19, 2017
66613d2
Merge pull request #409 from backfires/master
onlyliuxin Jun 19, 2017
eb66604
Merge pull request #406 from ilyle/master
onlyliuxin Jun 19, 2017
0522076
Merge pull request #407 from yangyangxu2016/master
onlyliuxin Jun 19, 2017
b31559a
Merge pull request #411 from kailuncen/cenkailun_ood_assign
onlyliuxin Jun 19, 2017
8356356
Merge pull request #412 from ericwang1984/master
onlyliuxin Jun 19, 2017
dcf49e0
Merge pull request #410 from silencehe09/master
onlyliuxin Jun 19, 2017
8900b20
Merge pull request #408 from Zering/master
onlyliuxin Jun 19, 2017
8a8a959
OCP练习
palmshe Jun 18, 2017
6a9087e
Merge branch 'master' of https://github.com/palmshe/coding2017
palmshe Jun 19, 2017
4b1e987
Merge branch 'master' of https://github.com/palmshe/coding2017
palmshe Jun 19, 2017
c6d4bc0
Merge branch 'master' of https://github.com/palmshe/coding2017
palmshe Jun 19, 2017
ce13e90
SRP 2.0-version
yuanfangblues Jun 19, 2017
8c21a20
OCP练习
palmshe Jun 19, 2017
62ed551
2017.6.19
Jun 19, 2017
3f84999
第一次作业 init2
miniyk2012 Jun 19, 2017
3c9da2d
Merge pull request #1 from onlyliuxin/master
miniyk2012 Jun 19, 2017
46f8aae
OCP 1.0-version
yuanfangblues Jun 19, 2017
d856a34
Merge pull request #1 from onlyliuxin/master
EtheriousNatsu Jun 19, 2017
1e80f7c
Submit for homework
Tony080 Jun 19, 2017
927e4ab
ood
walker113 Jun 19, 2017
4c068f5
重构PromotionMail满足SRP
jimmykwong Jun 20, 2017
473e0e8
重构PromotionMail满足SRP
jimmykwong Jun 20, 2017
bbafab3
重构PromotionMail满足SRP
jimmykwong Jun 20, 2017
08b18ae
Merge branch 'master' of https://github.com/lanyuanxiaoyao/coding2017
Jun 20, 2017
794103a
Merge pull request #2 from onlyliuxin/master
Jun 20, 2017
ee134d5
Merge pull request #421 from lanyuanxiaoyao/master
onlyliuxin Jun 20, 2017
b013f19
Merge pull request #420 from jimmykwong/master
onlyliuxin Jun 20, 2017
4440a01
Merge pull request #417 from Tony-Hu/master
onlyliuxin Jun 20, 2017
1dff723
Merge pull request #413 from LishaoyuVincent/master
onlyliuxin Jun 20, 2017
d11db59
Merge pull request #414 from palmshe/master
onlyliuxin Jun 20, 2017
9b5b947
Merge pull request #419 from walker113/master
onlyliuxin Jun 20, 2017
68438c9
Merge pull request #415 from begin16119/master
onlyliuxin Jun 20, 2017
eae3b01
提交作业,将发送邮件的作业拆分成3个类。希望老师看看是否合理
gukz Jun 20, 2017
1386588
Merge pull request #1 from onlyliuxin/master
fengdzh Jun 20, 2017
12d5766
readme
fengdzh Jun 20, 2017
8a6bb2b
删除文件。
Jun 20, 2017
09b0045
初始化创建文件。
Jun 20, 2017
8fbb80a
第二次作业参考答案
onlyliuxin Jun 20, 2017
e32df47
Merge branch 'master' of https://github.com/onlyliuxin/coding2017
onlyliuxin Jun 20, 2017
5c6cd6b
remove unused code
onlyliuxin Jun 20, 2017
3f9efb7
恢复被覆盖的文件
onlyliuxin Jun 20, 2017
d124ab2
恢复被删除的文件
onlyliuxin Jun 20, 2017
40aacb9
Delete test.txt
onlyliuxin Jun 20, 2017
4f161d3
删除文件
onlyliuxin Jun 20, 2017
80fb48c
第二次作业
Jun 20, 2017
5fd8ae3
初始化包结构。
Jun 20, 2017
104ac6a
增加ocp、srp module
Jun 20, 2017
899f529
完成ocp作业
zzJohnH Jun 20, 2017
b1d7d95
SRP
Tony080 Jun 20, 2017
c097274
Signed-off-by: 两次ood作业提交996108220@qq.com
Jun 20, 2017
c795b43
测试提交
Jun 20, 2017
6a71fd3
创建责任包,接口。
Jun 20, 2017
5d605f4
finish srp and ocp homework
szfck Jun 20, 2017
ded54f4
finish srp and ocp homework
szfck Jun 20, 2017
c7e1de9
merge
szfck Jun 20, 2017
2729efd
创建自己的代码
miniyk2012 Jun 20, 2017
96a90f2
重构邮件系统
Jun 20, 2017
288861e
重构日志打印类
hmgogo Jun 20, 2017
79ec6e0
push base source for SRP
Jun 21, 2017
4bab040
第二周作业
MIMIEYES Jun 21, 2017
8b1c73c
Create readme.md
MIMIEYES Jun 21, 2017
c63b581
modify project structure according to SRP rule
Jun 21, 2017
4af6dd9
Merge pull request #1 from onlyliuxin/master
IdenStudy Jun 21, 2017
e052e16
s
zhizx Jun 21, 2017
0d2da41
Merge pull request #432 from MIMIEYES/master
onlyliuxin Jun 21, 2017
2ed0766
Merge pull request #431 from hmgogo/master
onlyliuxin Jun 21, 2017
82fa8a4
Merge pull request #430 from litbai/master
onlyliuxin Jun 21, 2017
14181b6
123
zhizx Jun 21, 2017
aef65cd
第二次作业(找回第一次作业)
IdenStudy Jun 21, 2017
19d62a2
srp 原则。
fengdzh Jun 21, 2017
7c3eee9
Merge remote-tracking branch 'onlyliuxin/master'
GordenChow Jun 21, 2017
bc4a925
ood-ocp-homework
ericwang1984 Jun 21, 2017
9804e97
ood作业
Jun 21, 2017
4e2a19f
ood作业
Jun 21, 2017
6a4b511
pull base source of OCP
Jun 21, 2017
5af33a4
modify project according to OCP rule
Jun 21, 2017
d5e10f9
bug
Jun 21, 2017
988a409
第二季第二次作业
GordenChow Jun 21, 2017
fd45db2
Merge pull request #435 from ericwang1984/master
onlyliuxin Jun 21, 2017
3e1703a
第二季第一次大作业
skomefen Jun 21, 2017
ccc72ef
Merge branch 'master' of https://github.com/skomefen/coding2017
skomefen Jun 21, 2017
af06557
第二季第二次小作业
skomefen Jun 21, 2017
4e65053
第二次作业
yoda1990 Jun 21, 2017
2235a2e
第一次作业v2
miniyk2012 Jun 22, 2017
a84bcec
Revert "第一次作业 init2"
miniyk2012 Jun 22, 2017
0477883
srp homework refactor
onlyliuxin Jun 22, 2017
ae29f7a
Merge branch 'master' of https://github.com/onlyliuxin/coding2017
onlyliuxin Jun 22, 2017
7f14bb1
Merge pull request #1 from onlyliuxin/master
Rancher-V Jun 22, 2017
d85eb39
Merge remote-tracking branch 'upstream/master' 20170622
Jun 22, 2017
fbd64c7
add ocp refactor
harryhook Jun 22, 2017
d56ccb4
Merge pull request #2 from onlyliuxin/master
miniyk2012 Jun 22, 2017
4cd3a78
新建knowledge-point目录
onlyliuxin Jun 23, 2017
3f6b591
update SenderFactory
harryhook Jun 23, 2017
3e26f6d
update
yyglider Jun 23, 2017
294d918
Merge remote-tracking branch 'upstream/master'
Jun 23, 2017
697cd57
add srp
harryhook Jun 23, 2017
a5c9da9
refactor the sample of SRP in OOD.
ThomsonTang Jun 23, 2017
592e60b
refactor the sample
ThomsonTang Jun 23, 2017
38a9848
发邮件,重构2
miniyk2012 Jun 24, 2017
0defe07
Merge pull request #3 from onlyliuxin/master
miniyk2012 Jun 24, 2017
636f71c
第二周作业:打印不同的日志
miniyk2012 Jun 24, 2017
18a6b2d
打日志:重构代码
miniyk2012 Jun 24, 2017
b04dcdf
删除无用注释
miniyk2012 Jun 24, 2017
5a4663b
Merge pull request #1 from onlyliuxin/master
eulerlcs Jun 24, 2017
95d29e1
Merge pull request #2 from onlyliuxin/master
Rancher-V Jun 24, 2017
7082e05
创建责任包,接口。
Jun 24, 2017
178a362
ocp commit
Jun 24, 2017
d5f27cf
change the courseWork, add homework 2 and prepare to change
Rancher-V Jun 24, 2017
ad51ded
refactor second homework, refert to the good one
Rancher-V Jun 25, 2017
3a5dd12
first
ISmallBlack Jun 25, 2017
c624979
测试编码
ISmallBlack Jun 25, 2017
bf6493b
前面的作业
ISmallBlack Jun 25, 2017
1f5e3e3
发邮件的模板优化
miniyk2012 Jun 25, 2017
23bcc0e
创建多线程代码
miniyk2012 Jun 25, 2017
de9cb62
add homework for UML
Jun 26, 2017
c73d55c
ocp commit, 支持观察者
Jun 26, 2017
f6588e4
线程池使用1
miniyk2012 Jun 26, 2017
0738eb4
投骰子-代码部分
miniyk2012 Jun 26, 2017
2e94530
修改骰子的点数
miniyk2012 Jun 26, 2017
6840030
投骰子uml图
miniyk2012 Jun 26, 2017
cf5b22c
uml homework01
Jun 27, 2017
b9dcd70
srp homework
Jun 27, 2017
46f1749
read the file and resolve a line to a product.
ThomsonTang Jun 27, 2017
8bfc3ed
add a resource directory.
ThomsonTang Jun 27, 2017
7bd719e
购物网站用例图
miniyk2012 Jun 27, 2017
f4f6ef8
放大类图
miniyk2012 Jun 27, 2017
adea855
ocp homework
Jun 28, 2017
171e348
UML作业(dice game / shopping)
MIMIEYES Jun 28, 2017
a0496c3
refactor srp
Jun 29, 2017
0ab140f
refactor the promotion email project.
ThomsonTang Jun 29, 2017
2bc74af
单一职责作业
Jun 30, 2017
52f16e2
开闭原则作业
Jul 1, 2017
8d716de
refactor the promotion email project.
ThomsonTang Jul 2, 2017
35e5c7b
Merge pull request #474 from chasing95/master
onlyliuxin Jul 2, 2017
2b343ab
Merge pull request #2 from onlyliuxin/master
eulerlcs Jul 2, 2017
f69a583
第一次srp重构作业
Jul 2, 2017
6d58113
add regular expression project
eulerlcs Jul 2, 2017
431217d
第一次作业
em14Vito Jul 2, 2017
a66c7ab
Merge pull request #4 from onlyliuxin/master
miniyk2012 Jul 3, 2017
616cf8d
payroll
onlyliuxin Jul 4, 2017
e49ac3d
Merge pull request #478 from em14Vito/master
onlyliuxin Jul 4, 2017
d7270d2
Merge pull request #477 from imhuster/master
onlyliuxin Jul 4, 2017
96092ed
Merge pull request #1 from onlyliuxin/master
wluqing Jul 4, 2017
82c7cd3
Merge remote-tracking branch 'upstream/master'
Jul 4, 2017
e01d178
add project of payment
Jul 4, 2017
5813a06
Merge pull request #5 from onlyliuxin/master
miniyk2012 Jul 4, 2017
b714cf0
Payroll init
miniyk2012 Jul 4, 2017
70023ec
Merge pull request #476 from ThomsonTang/master
onlyliuxin Jul 5, 2017
6dfa138
Merge pull request #470 from MIMIEYES/master
onlyliuxin Jul 5, 2017
67e4eb4
Merge pull request #463 from starlight0405/master
onlyliuxin Jul 5, 2017
16fbe95
desktop commit
wluqing Jul 5, 2017
731e7e1
commit test
wluqing Jul 5, 2017
f20bea2
commit test2
wluqing Jul 5, 2017
f03f7ba
commit test undo
wluqing Jul 5, 2017
9c5a25d
commit test
wluqing Jul 5, 2017
048230a
commit and push test
wluqing Jul 5, 2017
fd74ffc
undo commit
wluqing Jul 5, 2017
0d1fbd3
Merge pull request #482 from wluqing/master
onlyliuxin Jul 6, 2017
30d1cb3
Merge pull request #457 from ISmallBlack/master
onlyliuxin Jul 6, 2017
89de58a
Merge pull request #1 from onlyliuxin/master
harryhook Jul 6, 2017
5be0c63
payroll
Jul 9, 2017
b5f9d48
Revert "payroll"
Jul 9, 2017
aba6c86
payroll
Jul 9, 2017
2ae6521
Merge branch 'master' of https://github.com/guoshenghui/coding2017
Jul 9, 2017
c5cdc21
payroll code
onlyliuxin Jul 10, 2017
323a02a
payroll code
onlyliuxin Jul 10, 2017
22d8938
paroll code
onlyliuxin Jul 10, 2017
cb12f47
Merge pull request #462 from guoshenghui/master
onlyliuxin Jul 10, 2017
4e92eff
Merge pull request #454 from yyglider/master
onlyliuxin Jul 10, 2017
e6e5cf8
Merge pull request #453 from fengdzh/master
onlyliuxin Jul 10, 2017
b358bd5
Merge pull request #452 from Rancher-V/master
onlyliuxin Jul 10, 2017
faa1a3a
Merge pull request #449 from HarryHook/master
onlyliuxin Jul 10, 2017
9f2c2ae
Merge pull request #447 from miniyk2012/master
onlyliuxin Jul 10, 2017
2330282
Merge pull request #445 from YouHmilyForProgramming/master
onlyliuxin Jul 10, 2017
209c893
Merge pull request #442 from skomefen/master
onlyliuxin Jul 10, 2017
12769d2
Merge pull request #440 from yangzhm/master
onlyliuxin Jul 10, 2017
3125a34
Merge pull request #437 from GordenChow/master
onlyliuxin Jul 10, 2017
89d9463
Merge pull request #436 from javmin/master
onlyliuxin Jul 10, 2017
fc122f1
Merge pull request #433 from ShiningChenCode/master
onlyliuxin Jul 10, 2017
483827e
Merge pull request #429 from szfck/master
onlyliuxin Jul 10, 2017
17e1f55
Merge pull request #428 from 15993061515/master
onlyliuxin Jul 10, 2017
13b44e6
Merge pull request #427 from WANGCANCER/master
onlyliuxin Jul 10, 2017
f17529d
Merge pull request #426 from Tony-Hu/master
onlyliuxin Jul 10, 2017
e0bb3fa
Merge pull request #425 from johnChnia/master
onlyliuxin Jul 10, 2017
edc5836
Merge pull request #423 from Ken-W-P-Huang/master
onlyliuxin Jul 10, 2017
1b68f6c
Merge pull request #422 from GUK0/master
onlyliuxin Jul 10, 2017
3aa27a3
payroll code
onlyliuxin Jul 10, 2017
a98dea4
tag builder
onlyliuxin Jul 10, 2017
e69f85c
第一次作业linxin目录下文件修改误提交,现在重提交
KeXianlin Jul 10, 2017
34e00d5
uml homework
Jul 11, 2017
096522a
添加正则表达式用例
eulerlcs Jul 11, 2017
3a498c3
Merge pull request #3 from onlyliuxin/master
eulerlcs Jul 11, 2017
5c16127
add regexp project
eulerlcs Jul 12, 2017
d60b463
Merge pull request #496 from eulerlcs/20170712.regexp
onlyliuxin Jul 12, 2017
76c02c1
Merge pull request #491 from readke/master
onlyliuxin Jul 13, 2017
2a2be7c
Merge pull request #492 from starlight0405/master
onlyliuxin Jul 13, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ target
liuxin/.DS_Store
liuxin/src/.DS_Store

students/1005475328/*
students/1329920463/*
students/1452302762/*
students/14703250/*
students/2842295913/*
students/383117348/*
students/404481481/*
students/406400373/*
students/549739951/*
students/582161208/*
students/592146505/*
students/740707954/*
students/844620174/*
students/87049319/*
students/183549495/*





Expand Down
Binary file added dicegame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@ public void testIsValid() {
public void testGetNodesBetween(){
List<Integer> numbers = this.tree.getNodesBetween(3, 8);
Assert.assertEquals("[3, 4, 5, 6, 8]",numbers.toString());
numbers = this.tree.getNodesBetween(1, 8);
Assert.assertEquals("[1, 2, 3, 4, 5, 6, 8]",numbers.toString());
}
}
32 changes: 32 additions & 0 deletions liuxin/knowledge-point/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.coderising</groupId>
<artifactId>knowledge-point</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>knowledge-point</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>
<repositories>
<repository>
<id>aliyunmaven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
18 changes: 18 additions & 0 deletions liuxin/knowledge-point/src/main/java/cas/CASSequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cas;

import java.util.concurrent.atomic.AtomicInteger;

public class CASSequence{

private AtomicInteger count = new AtomicInteger(0);

public int next(){
while(true){
int current = count.get();
int next = current +1;
if(count.compareAndSet(current, next)){
return next;
}
}
}
}
34 changes: 34 additions & 0 deletions liuxin/knowledge-point/src/main/java/cas/NoBlockingStack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cas;

import java.util.concurrent.atomic.AtomicReference;

public class NoBlockingStack<E> {
static class Node<E> {
final E item;
Node<E> next;
public Node(E item) { this.item = item; }
}

AtomicReference<Node<E>> head = new AtomicReference<Node<E>>();

public void push(E item) {
Node<E> newHead = new Node<E>(item);
Node<E> oldHead;
do {
oldHead = head.get();
newHead.next = oldHead;
} while (!head.compareAndSet(oldHead, newHead));
}
public E pop() {
Node<E> oldHead;
Node<E> newHead;
do {
oldHead = head.get();
if (oldHead == null)
return null;
newHead = oldHead.next;
} while (!head.compareAndSet(oldHead,newHead));
return oldHead.item;
}

}
11 changes: 11 additions & 0 deletions liuxin/knowledge-point/src/main/java/cas/Sequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cas;

public class Sequence{

private int value;

public int next(){
return value ++;
}

}
20 changes: 20 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadlocal/Context.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package threadlocal;
import java.util.HashMap;
import java.util.Map;

public class Context {

private static final ThreadLocal<String> txThreadLocal
= new ThreadLocal<String>();

public static void setTransactionID(String txID) {
txThreadLocal.set(txID);

}

public static String getTransactionId() {
return txThreadLocal.get();
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package threadlocal;

public class TransactionManager {
private static final ThreadLocal<String> context = new ThreadLocal<String>();

public static void startTransaction() {
// logic to start a transaction
// ...
String txID = null;
context.set(txID);
}

public static String getTransactionId() {
return context.get();
}

public static void endTransaction() {
// logic to end a transaction
// …
context.remove();
}
}
35 changes: 35 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/BlockingQueue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package threadpool;
import java.util.LinkedList;
import java.util.List;

public class BlockingQueue {

private List queue = new LinkedList();
private int limit = 10;

public BlockingQueue(int limit) {
this.limit = limit;
}

public synchronized void enqueue(Object item) throws InterruptedException {
while (this.queue.size() == this.limit) {
wait();
}
if (this.queue.size() == 0) {
notifyAll();
}
this.queue.add(item);
}

public synchronized Object dequeue() throws InterruptedException {
while (this.queue.size() == 0) {
wait();
}
if (this.queue.size() == this.limit) {
notifyAll();
}

return this.queue.remove(0);
}

}
5 changes: 5 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package threadpool;

public interface Task {
public void execute();
}
37 changes: 37 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/ThreadPool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package threadpool;
import java.util.ArrayList;
import java.util.List;


public class ThreadPool {

private BlockingQueue taskQueue = null;
private List<WorkerThread> threads = new ArrayList<WorkerThread>();
private boolean isStopped = false;

public ThreadPool(int numOfThreads, int maxNumOfTasks){
taskQueue = new BlockingQueue(maxNumOfTasks);

for(int i=0; i<numOfThreads; i++){
threads.add(new WorkerThread(taskQueue));
}
for(WorkerThread thread : threads){
thread.start();
}
}

public synchronized void execute(Task task) throws Exception{
if(this.isStopped) throw
new IllegalStateException("ThreadPool is stopped");

this.taskQueue.enqueue(task);
}

public synchronized void stop(){
this.isStopped = true;
for(WorkerThread thread : threads){
thread.doStop();
}
}

}
33 changes: 33 additions & 0 deletions liuxin/knowledge-point/src/main/java/threadpool/WorkerThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package threadpool;


public class WorkerThread extends Thread {

private BlockingQueue taskQueue = null;
private boolean isStopped = false;

public WorkerThread(BlockingQueue queue){
taskQueue = queue;
}

public void run(){
while(!isStopped()){
try{
Task task = (Task) taskQueue.dequeue();
task.execute();
} catch(Exception e){
//log or otherwise report exception,
//but keep pool thread alive.
}
}
}

public synchronized void doStop(){
isStopped = true;
this.interrupt(); //break pool thread out of dequeue() call.
}

public synchronized boolean isStopped(){
return isStopped;
}
}
14 changes: 13 additions & 1 deletion liuxin/ood/ood-assignment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
<groupId>com.coderising</groupId>
<artifactId>ood-assignment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>

<name>ood-assignment</name>
<url>http://maven.apache.org</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.coderising.dp.builder;

public class TagBuilder {

public TagBuilder(String rootTagName){

}

public TagBuilder addChild(String childTagName){

return null;
}
public TagBuilder addSibling(String siblingTagName){


return null;

}
public TagBuilder setAttribute(String name, String value){

return null;
}
public TagBuilder setText(String value){

return null;
}
public String toXML(){
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.coderising.dp.builder;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TagBuilderTest {

@Before
public void setUp() throws Exception {
}

@After
public void tearDown() throws Exception {
}

@Test
public void testToXML() {

TagBuilder builder = new TagBuilder("order");

String xml = builder.addChild("line-items")
.addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3")
.addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10")
.toXML();

String expected = "<order>"
+ "<line-items>"
+ "<line-item pid=\"P3677\" qty=\"3\"/>"
+ "<line-item pid=\"P9877\" qty=\"10\"/>"
+ "</line-items>"
+ "</order>";

System.out.println(xml);
assertEquals(expected, xml);
}

}
Loading