草稿箱
中转站
http://blog.****.net/shan9liang/article/details/37598305
http://blog.****.net/cutesource/article/details/5864562
https://www.zhihu.com/collection/98051517
http://www.layui.com/doc/modules/layer.html
http://blog.****.net/jiuqiyuliang/article/details/48758203
http://ifeve.com/memory-barriers-or-fences/
https://www.zhihu.com/question/24518251
https://www.ibm.com/developerworks/cn/education/java/j-nio/index.html
https://tech.meituan.com/nio.html
http://blog.****.net/zhuohaiyy/article/details/64440677
http://blog.****.net/zhangdaiscott/article/details/51878400
并发编程学习方法论
- 并发编程网;
- java并发编程实战;
- Effective Java 并发编程部分;
- 历年校招、社招多线程题目;
- 多线程的实际应用;
# resolve links - $0 may be asoftlink
PRG="$0" <--- 执行程序名
#以下循环判断可执行文件是否是一个符号连接(symbolic link,也叫软连接),如果是符号连接,找到实际指向的文件位置
while[ -h "$PRG" ] ; do
ls=`ls-ld "$PRG"`
link=`expr"$ls" : '.*-> \(.*\)$'`
ifexpr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname"$PRG"`/"$link"
fi
done
#此时,$PRG 指向实际的文件
PRGDIR=`dirname"$PRG"`
EXECUTABLE=catalina.sh
#Check that target executable exists
#判断这个实际的目标文件是否存在且是可执行文件
if [! -x "$PRGDIR"/"$EXECUTABLE" ]; then
echo"Cannot find $PRGDIR/$EXECUTABLE"
echo"This file is needed to run this program"
exit1
fi
#执行目标文件
exec"$PRGDIR"/"$EXECUTABLE" stop "[email protected]"
这个脚本的目的是解决通过符号连接去执行一个程序的问题。如果是符号连接,需要找到实际指向的目标文件,然后再执行它的stop 命令。
-h :-h FILE FILE exists and is a symbolic link (same as-L)
-h用来判断$PRG文件是否存在并且是一个符号链接,所以你这段脚本就是当$PRG存在并且是符号链接时执行do~done之间的脚本
参考资料: http://linux.about.com/library/cmd/blcmdl1_test.htm
dirname: 取得路径的目录名称;
basename:取得路径的文件名称;
[email protected]:代表参数的全部内容;
/dev/null:
link=`expr "$ls" : '.*-> \(.*\)$'`中:
expr:表示要根据某个模式去匹配字符串并返回所匹配到的字符串,或根据某个模式去计算匹配到的字符数。使用方式一般为: expr value : expression。"$ls"表示取变量 ls 中的内容。
'.*-> \(.*\)$':这部分是一个正则表达式, .*部分表示任意字符, -> 是实际的两个字符, Linux中的软链接会在使用ls -al命令列出文件的时候,以 "软链接 ->真实文件"的方式显示出软链接与其所链接的真实文件。$在这里表示行结束 \(就是 (,因为 ( shell中属于特殊符号,所以需要使用转义; \)同样是转义为 );
整个 `expr "$ls" : '.*->\(.*\)$'`就表示取到软连接的真实文件或真实目录。
来自 <https://zhidao.baidu.com/question/511088230.html>