lock 关键字将语句块标记为临界区,方法是获取给定对象的互斥锁,执行语句,然后释放该锁。lock语句根本使用的就是Monitor.Enter和Monitor.Exit,也就是说lock(this)时执行Monitor.Enter(this),大括号结束时执行Monitor.Exit(this).他...
分类:
其他好文 时间:
2014-07-22 00:31:36
阅读次数:
242
import queue,threading l=threading.Lock()class MyThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) global...
分类:
编程语言 时间:
2014-07-22 00:20:34
阅读次数:
189
bool flock ( int handle, int operation [, int &wouldblock] );flock() 操作的 handle 必须是一个已经打开的文件指针。operation 可以是以下值之一:要取得共享锁定(读取程序),将 operation 设为 LOCK_SH...
分类:
Web程序 时间:
2014-07-22 00:07:34
阅读次数:
278
LOCK_EX是表示排它锁(Exclude),是独占的,一般用于写操作,而如果换成LOCK_SH(Share)则是共享,多用于读取。有时为了保证多进程对文件的读写都是唯一的,无论读写都进行LOCK_EX的请求。 以下是一段演示程序,...
分类:
其他好文 时间:
2014-07-21 23:31:03
阅读次数:
238
使用步骤: 步骤一、在spring配置文件中引入<tx:>命名空间 <beans xmlns="http://www.springframework.org/schema/beans" ?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ?xmlns:tx="http://www.spri...
分类:
编程语言 时间:
2014-07-21 23:29:22
阅读次数:
392
一、通过pip工具安装
https://pypi.python.org/pypi/pip#downloads
cd /opt/
tar xzvf pip-1.5.6.tar.gz
cd /opt/pip-1.5.6
python setup.py install
pip install ngxtop
ngxtop -c /usr/local/nginx/conf/nginx.co...
分类:
其他好文 时间:
2014-07-21 23:28:11
阅读次数:
258
开发人员在本地提交更新到SVN服务器后,往往需要测试人员重新测试。为了将更新内容即时反映到测试服务器,可以利用post-commit脚本将SVN更新同步到测试服务器中。
(1)利用SVN的工作副本(WORKINGCOPY)创建TOMCATWEB项目
cd /opt/tomcat_home/webapps
svn co svn://svn_host/prjname/trunk prjname
...
分类:
Web程序 时间:
2014-07-21 23:12:53
阅读次数:
480
Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co...
分类:
其他好文 时间:
2014-07-21 14:11:16
阅读次数:
151
一:为了更好的在GDB中显示STL容器,我们首先要下载一个python脚本
PS:要确定你所安装的GDB可以执行python脚本cd ~
mkdir .gdb
cd .gdb
svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
二:修改用户目录下的.gdbinit文件(将以下文本复制一份就行)#为了更好的在GDB中显示STL...
分类:
数据库 时间:
2014-07-21 14:04:27
阅读次数:
248
主要区别1、Lock能完成几乎所有synchronized的功能,并有一些后者不具备的功能,如公平锁、等待可中断、锁绑定多个条件等;2、synchronized是Java
语言层面的,是内置的关键字;Lock则是JDK5中出现的一个包,在使用时,synchronized
同步的代码块可以由JVM自动释放;Lock需要程..
分类:
编程语言 时间:
2014-07-21 12:46:35
阅读次数:
254