世人笑我太孤单
aahyhaa · 共 8 篇文章
Volatile关键字的作用
It is possible for each thread to have a local stack and maintain copies of some variables there. If you define a variable as volatile, it tells the compiler not to do any optimizations that would remove reads and writes that keep the field in exact synchronization with the local data in the thread…
2013-03-27 10:07 · Java · 评论(0)
Atomicity and volatility
Atomicity applies to "simple operations" on primitive types except for longs and doubles. Reading and writing primitive variables other than long and double is guaranteed to go to and from memory as indivisible (atomic) operations. However, the JVM is allowed to perform reads and writes of 64- bit …
2013-03-26 15:52 · Java · 评论(0)
什么时候用到synchronize关键字?
When should you synchronize? Apply Brian’s Rule of Synchronization If you are writing a variable that might next be read by another thread, or reading a variable that might have last been written by another thread, you must use synchronization, and further, both the reader and the writer must synch…
2013-03-26 10:42 · Java · 评论(0)
多线程重要概念(一)
All objects automatically contain a single lock (also referred to as a monitor). When you call any synchronized method, that object is locked and no other synchronized method of that object can be called until the first one finishes and releases the lock. For the preceding methods, if f( ) is calle…
2013-03-25 17:20 · Java · 评论(0)
js float类型数据的加减乘除bug修复
var FloatCalFun=new Object(); //获取参数精度,如果为整数则精度为0 FloatCalFun._getPrecision=function(arg){ if(arg.toString().indexOf(".")==-1){ return 0; }else{ return arg.toString().split(".")[1].length; } } //获取小数的整数形式 FloatCalFun._getIntFromFloat=function(arg){ if(arg.toString().indexOf(".")==-1){ return arg; }…
2013-01-06 17:42 · Javascript · 评论(0)
如何让自己的电脑通过无线虚拟网络共享成为热点。
将win7电脑变身WiFi热点,让手机、笔记本共享上网 用win7建立无线局域网,可以共享上网可以局域网游戏。 开启windows 7的隐藏功能:虚拟WiFi和SoftAP(即虚拟无线AP),就可以让电脑变成无线路由器,实现共享上网,节省网费和路由器购买费。宏碁、惠普笔记本和诺基亚N97mini亲测通过。 以操作系统为win7的笔记本或装有无线网卡的台式机作为主机。 主机设置如下: 1、以管理员身份运行命令提示符: 快捷键win+R→输入cmd→回车 2、启用并设定虚拟WiFi网卡: 运行命令:netsh wlan set hostednetwork mode=allow ssid=houy…
2013-01-06 14:06 · 杂谈 · 评论(0)
判断请求是否为ajax请求
注明:该方法只限在jquery中的ajax请求,作者只在jquery中做过测试。 public boolean isAjaxRequest(HttpServletRequest request){ String requestHeader=request.getHeader("X-Requested-With"); if(requestHeader!=null&&requestHeader.equalsIgnoreCase("XMLHttpRequest")){ return true; }else{ return false; } 测试浏览器:IE8、firefox、chrome
2013-01-06 14:04 · Javascript · 评论(0)
java线程和操作系统进程的关系
One very straightforward way to implement concurrency is at the operating system level, using processes. A process is a self-contained program running within its own address space. A multitasking operating system can run more than one process (program) at a time by periodically switching the CPU fr…
2013-01-06 13:59 · Java · 评论(0)