<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《Java轻量级锁原理详解(Lightweight Locking)》的评论</title>
	<atom:link href="http://kenwublog.com/theory-of-lightweight-locking-upon-cas/feed" rel="self" type="application/rss+xml" />
	<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas</link>
	<description>just another software engineer blog</description>
	<lastBuildDate>Tue, 08 May 2012 03:14:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>作者：Java 6 JVM参数选项大全（中文版） &#124; 那些年，那些事</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-32193</link>
		<dc:creator>Java 6 JVM参数选项大全（中文版） &#124; 那些年，那些事</dc:creator>
		<pubDate>Fri, 06 Jan 2012 09:17:08 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-32193</guid>
		<description>[...] CAS检测锁的原理详见: http://kenwublog.com/theory-of-lightweight-locking-upon-cas 关联选项： -XX:PreBlockSpin=10 [...]</description>
		<content:encoded><![CDATA[<p>[...] CAS检测锁的原理详见: http://kenwublog.com/theory-of-lightweight-locking-upon-cas 关联选项： -XX:PreBlockSpin=10 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：snake1987</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30525</link>
		<dc:creator>snake1987</dc:creator>
		<pubDate>Thu, 14 Apr 2011 01:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30525</guid>
		<description>谢谢您的回答</description>
		<content:encoded><![CDATA[<p>谢谢您的回答</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：Ken Wu</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30524</link>
		<dc:creator>Ken Wu</dc:creator>
		<pubDate>Wed, 13 Apr 2011 13:58:57 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30524</guid>
		<description>1，怎么补救，就是进入mutex前，compare一下obj的mark word状态。确认该mark是否被其他线程持有。
此时如果线程已经释放了mark，那么通过CAS后就可以直接进入线程，无需进入mutex.这就这个作用。

2，轻量级锁只是普通锁的一个优化。就是堆一个变量的CAS操作。你理解对的。</description>
		<content:encoded><![CDATA[<p>1，怎么补救，就是进入mutex前，compare一下obj的mark word状态。确认该mark是否被其他线程持有。<br />
此时如果线程已经释放了mark，那么通过CAS后就可以直接进入线程，无需进入mutex.这就这个作用。</p>
<p>2，轻量级锁只是普通锁的一个优化。就是堆一个变量的CAS操作。你理解对的。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：snake1987</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30521</link>
		<dc:creator>snake1987</dc:creator>
		<pubDate>Sat, 09 Apr 2011 13:10:51 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30521</guid>
		<description>上面第一行“也看过”后面应该是concurrent in practice，不知道怎么，加了个书名号就显示不出来了</description>
		<content:encoded><![CDATA[<p>上面第一行“也看过”后面应该是concurrent in practice，不知道怎么，加了个书名号就显示不出来了</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：snake1987</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30520</link>
		<dc:creator>snake1987</dc:creator>
		<pubDate>Sat, 09 Apr 2011 13:09:10 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30520</guid>
		<description>也看过，包括JDK的AQS的源码
基本看完了楼主的前几篇并发相关的文章，其实就是里面的内容
但这篇轻量级锁没看到过

反反复复看了三遍，发现还是没看明白
总的来说，觉得博主有几个问题没讲清楚
1.文中说：
“轻量级锁（Lightweight Locking）本意是为了减少多线程进入互斥的几率，并不是要替代互斥。
它利用了CPU原语Compare-And-Swap(CAS，汇编指令CMPXCHG)，尝试在进入互斥前，进行补救。
”
但其实博文中并没有描述怎么补救的，也没有解释怎么能减少进入互斥的几率了
2.博文中的图片上的处理逻辑，仔细看了，也没发现轻量级锁的优越性体现在哪里了，跟普通锁比较感觉不到区别（我自己没了解过虚拟机层次普通锁的实现，只是从表现上推断），都是获取锁，失败等待，成功运行。
3.个人感觉，文中的所谓的轻量级锁的原理，其实也是归结为对一个变量的CAS操作而已，跟AQS的原理其实没什么区别
（当然，这是小弟个人的看法，还希望博主对这几个问题解释一下，感激不尽）</description>
		<content:encoded><![CDATA[<p>也看过，包括JDK的AQS的源码<br />
基本看完了楼主的前几篇并发相关的文章，其实就是里面的内容<br />
但这篇轻量级锁没看到过</p>
<p>反反复复看了三遍，发现还是没看明白<br />
总的来说，觉得博主有几个问题没讲清楚<br />
1.文中说：<br />
“轻量级锁（Lightweight Locking）本意是为了减少多线程进入互斥的几率，并不是要替代互斥。<br />
它利用了CPU原语Compare-And-Swap(CAS，汇编指令CMPXCHG)，尝试在进入互斥前，进行补救。<br />
”<br />
但其实博文中并没有描述怎么补救的，也没有解释怎么能减少进入互斥的几率了<br />
2.博文中的图片上的处理逻辑，仔细看了，也没发现轻量级锁的优越性体现在哪里了，跟普通锁比较感觉不到区别（我自己没了解过虚拟机层次普通锁的实现，只是从表现上推断），都是获取锁，失败等待，成功运行。<br />
3.个人感觉，文中的所谓的轻量级锁的原理，其实也是归结为对一个变量的CAS操作而已，跟AQS的原理其实没什么区别<br />
（当然，这是小弟个人的看法，还希望博主对这几个问题解释一下，感激不尽）</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：Ken Wu</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30443</link>
		<dc:creator>Ken Wu</dc:creator>
		<pubDate>Mon, 20 Dec 2010 13:09:04 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30443</guid>
		<description>网上有很多啊，你google一下就找到了。
当然，也可以去 oracle.com, wikipedia.com 搜...</description>
		<content:encoded><![CDATA[<p>网上有很多啊，你google一下就找到了。<br />
当然，也可以去 oracle.com, wikipedia.com 搜&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：jasin2008</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30440</link>
		<dc:creator>jasin2008</dc:creator>
		<pubDate>Sat, 18 Dec 2010 10:41:47 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30440</guid>
		<description>大侠有什么好的参考资料推荐么</description>
		<content:encoded><![CDATA[<p>大侠有什么好的参考资料推荐么</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：Java 6 JVM参数选项大全（中文版） &#171; 这儿的空间，没什么新鲜</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30371</link>
		<dc:creator>Java 6 JVM参数选项大全（中文版） &#171; 这儿的空间，没什么新鲜</dc:creator>
		<pubDate>Wed, 15 Sep 2010 20:45:42 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30371</guid>
		<description>[...] CAS检测锁的原理详见:&#160;http://kenwublog.com/theory-of-lightweight-locking-upon-cas关联选项：-XX:PreBlockSpin=10 [...]</description>
		<content:encoded><![CDATA[<p>[...] CAS检测锁的原理详见:&nbsp;<a href="http://kenwublog.com/theory-of-lightweight-locking-upon-cas关联选项：-XX:PreBlockSpin=10" rel="nofollow">http://kenwublog.com/theory-of-lightweight-locking-upon-cas关联选项：-XX:PreBlockSpin=10</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：sking</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30354</link>
		<dc:creator>sking</dc:creator>
		<pubDate>Thu, 26 Aug 2010 14:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30354</guid>
		<description>高手 呵呵</description>
		<content:encoded><![CDATA[<p>高手 呵呵</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：这儿的空间，没什么新鲜 &#187; Java 6 JVM参数选项大全（中文版）</title>
		<link>http://kenwublog.com/theory-of-lightweight-locking-upon-cas/comment-page-1#comment-30305</link>
		<dc:creator>这儿的空间，没什么新鲜 &#187; Java 6 JVM参数选项大全（中文版）</dc:creator>
		<pubDate>Mon, 05 Jul 2010 08:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://kenwublog.com/?p=985#comment-30305</guid>
		<description>[...] CAS检测锁的原理详见:?http://kenwublog.com/theory-of-lightweight-locking-upon-cas 关联选项： -XX:PreBlockSpin=10 [...]</description>
		<content:encoded><![CDATA[<p>[...] CAS检测锁的原理详见:?<a href="http://kenwublog.com/theory-of-lightweight-locking-upon-cas" rel="nofollow">http://kenwublog.com/theory-of-lightweight-locking-upon-cas</a> 关联选项： -XX:PreBlockSpin=10 [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

