<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:www.nabble.com,2006:forum-2681</id>
	<title>Nabble - JSR166 Concurrency</title>
	<updated>2008-09-06T11:43:01Z</updated>
	<link rel="self" type="application/atom+xml" href="http://www.nabble.com/JSR166-Concurrency-f2681.xml" />
	<link rel="alternate" type="text/html" href="http://www.nabble.com/JSR166-Concurrency-f2681.html" />
	<subtitle type="html">&lt;a href=&quot;http://gee.cs.oswego.edu/dl/concurrency-interest/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;JSR 166 Concurrency Utilities&lt;/a&gt;: The JSR (Java Specification Requests) proposes a set of medium-level utilities that provide functionality commonly needed in concurrent programs.</subtitle>
	
<entry>
	<id>tag:www.nabble.com,2006:post-19350032</id>
	<title>Re: Project FishFarm; making a ForkJoinPool distributeable</title>
	<published>2008-09-06T11:43:01Z</published>
	<updated>2008-09-06T11:43:01Z</updated>
	<author>
		<name>Doug Lea</name>
	</author>
	<content type="html">Sorry for the long delay replying to this!
&lt;br&gt;&lt;br&gt;Michael Bien wrote:
&lt;br&gt;&amp;gt; -made ForkJoinTask Serializeable
&lt;br&gt;&lt;br&gt;We can't mandate that all ForkJoinTasks are serializable.
&lt;br&gt;In a non-JDK release maybe we could, because then we
&lt;br&gt;could just tell people creating subclasses (which is the main
&lt;br&gt;way you use FJ) to ignore the serializablility
&lt;br&gt;if they don't need it, because nothing actually relies on it.
&lt;br&gt;An alternative would be to introduce SerializableForkJoinTask,
&lt;br&gt;but then we'd need the basic exec internals fleshed out for
&lt;br&gt;the various main flavors (SerializableRecursiveAction etc)
&lt;br&gt;because we don't/can't allow people to implement these themselves.
&lt;br&gt;&lt;br&gt;Further, all you really want here is to
&lt;br&gt;ensure that arguments and results are serializable. Sadly
&lt;br&gt;you can't write this as a conjunctive type like:
&lt;br&gt;&amp;nbsp; &amp;nbsp; void foo([ForkJoinTask &amp; Serializable] task)
&lt;br&gt;So my best suggestion, sadly enough, is to rely on
&lt;br&gt;dynamic typing, as in:
&lt;br&gt;&amp;nbsp; &amp;nbsp; void foo(ForkJoinTask task) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!(task implements Serializable)) throw...
&lt;br&gt;&lt;br&gt;Which would then entail javadoc @param specs etc that
&lt;br&gt;spell out the otherwise unstated type requirements.
&lt;br&gt;&lt;br&gt;(Perhaps someone has already created an annotation tag
&lt;br&gt;along these lines?)
&lt;br&gt;&lt;br&gt;How bad would that be?
&lt;br&gt;&lt;br&gt;&amp;gt; -added popQuedTask() to ForkJoinPool which returns a not-yet executed 
&lt;br&gt;&amp;gt; task and removes it from the pool (i am pretty sure this will not work 
&lt;br&gt;&amp;gt; under all conditions)
&lt;br&gt;&lt;br&gt;You mean a submission to a pool, right?
&lt;br&gt;That is now possible via ForkJoinWorkerThread.pollSubmission.
&lt;br&gt;It seems somewhat dangerous to expose the ForkJoinPool version
&lt;br&gt;so that non-FJ code can remove tasks, but maybe there is
&lt;br&gt;a good argument for it?
&lt;br&gt;&lt;br&gt;&amp;gt; -added getTask() to Submission
&lt;br&gt;&lt;br&gt;The Submission class is not even public, so this
&lt;br&gt;by itself wouldn't do much good. For plumbing-level
&lt;br&gt;manipulation though, perhaps you could use privileged
&lt;br&gt;reflection to directly access the task field?
&lt;br&gt;&lt;br&gt;-Doug
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19350032&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Project-FishFarm--making-a-ForkJoinPool-distributeable-tp17679302p19350032.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19349410</id>
	<title>Re: forkjoin updates</title>
	<published>2008-09-06T10:37:50Z</published>
	<updated>2008-09-06T10:37:50Z</updated>
	<author>
		<name>Tim Clendenen</name>
	</author>
	<content type="html">&lt;html&gt;
&lt;head&gt;

&lt;/head&gt;
&lt;body class='hmmessage'&gt;
The BasicAsyncAction class doesn't appear to be in CVS.&lt;br&gt;&lt;br&gt;Doug Lea wrote:&lt;br&gt;&gt; An updated jsr166y package is available. The changes&lt;br&gt;&gt; are mainly focussed on internal reducing overhead and improving&lt;br&gt;&gt; scalability. There are some visible changes though:&lt;br&gt;&gt;&lt;br&gt;&gt; * Phasers now support tiering -- you can create trees&lt;br&gt;&gt; of them to reduce contention. (Initial plans were&lt;br&gt;&gt; to do this internally/adaptively, but exposing&lt;br&gt;&gt; it leaving it up to users works out better.)&lt;br&gt;&gt;&lt;br&gt;&gt; * AsyncAction is now a base class for (existing) class&lt;br&gt;&gt; LinkedAsyncAction, along with new classes BasicAsyncAction&lt;br&gt;&gt; (a minimal implementation) and BinraryAsyncAction. Async&lt;br&gt;&gt; actions take some attitude adjustment to get used to, but&lt;br&gt;&gt; are more flexible than Recursive{Action,Task}.&lt;br&gt;&gt;&lt;br&gt;&gt; * CyclicAction has disappeared, probably to be replaced&lt;br&gt;&gt; by better support for mixing long-lived looping threads&lt;br&gt;&gt; running in ExecutorServices with data-parallel tasks running&lt;br&gt;&gt; in ForkJoinPools. (Which is possible even now, but not&lt;br&gt;&gt; always easy to set up.) Similarly for Phaser integration.&lt;br&gt;&gt;&lt;br&gt;&gt; * A few small utility methods that probably no&lt;br&gt;&gt; one has used have gone away, and a few better&lt;br&gt;&gt; documented ones introduced.&lt;br&gt;&gt;&lt;br&gt;&gt; Some of the main streamlining improvements rely on&lt;br&gt;&gt; Java6 features. (It also runs of course on&lt;br&gt;&gt; early-access versions of openjdk/jdk7.)&lt;br&gt;&gt; There is no longer even internal guidance on&lt;br&gt;&gt; how to adapt for Java5. If you must run on Java5, you&lt;br&gt;&gt; probably want to keep using older snaphots.&lt;br&gt;&gt;&lt;br&gt;&gt; Comments welcome as always. Things are in their usual places:&lt;br&gt;&gt; API specs:&lt;br&gt;&gt;   http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/&lt;br&gt;&gt; jar file:&lt;br&gt;&gt;   http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166y.jar&lt;br&gt;&gt; Browsable CVS sources:&lt;br&gt;&gt;   http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166y/&lt;br&gt;&gt;&lt;br&gt;&gt; -Doug&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; _______________________________________________&lt;br&gt;&gt; Concurrency-interest mailing list&lt;br&gt;&gt; &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19349410&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;&lt;br&gt;&gt; http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;hr /&gt;Get more out of the Web. Learn 10 hidden secrets of Windows Live. &lt;a href='http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_getmore_092008' target='_new' rel=&quot;nofollow&quot;&gt;Learn Now&lt;/a&gt;&lt;/body&gt;
&lt;/html&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19349410&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/forkjoin-updates-tp19347229p19349410.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19347229</id>
	<title>forkjoin updates</title>
	<published>2008-09-06T07:08:31Z</published>
	<updated>2008-09-06T07:08:31Z</updated>
	<author>
		<name>Doug Lea</name>
	</author>
	<content type="html">An updated jsr166y package is available. The changes
&lt;br&gt;are mainly focussed on internal reducing overhead and improving
&lt;br&gt;scalability. There are some visible changes though:
&lt;br&gt;&lt;br&gt;* Phasers now support tiering -- you can create trees
&lt;br&gt;of them to reduce contention. (Initial plans were
&lt;br&gt;to do this internally/adaptively, but exposing
&lt;br&gt;it leaving it up to users works out better.)
&lt;br&gt;&lt;br&gt;* AsyncAction is now a base class for (existing) class
&lt;br&gt;LinkedAsyncAction, along with new classes BasicAsyncAction
&lt;br&gt;(a minimal implementation) and BinraryAsyncAction. Async
&lt;br&gt;actions take some attitude adjustment to get used to, but
&lt;br&gt;are more flexible than Recursive{Action,Task}.
&lt;br&gt;&lt;br&gt;* CyclicAction has disappeared, probably to be replaced
&lt;br&gt;by better support for mixing long-lived looping threads
&lt;br&gt;running in ExecutorServices with data-parallel tasks running
&lt;br&gt;in ForkJoinPools. (Which is possible even now, but not
&lt;br&gt;always easy to set up.) Similarly for Phaser integration.
&lt;br&gt;&lt;br&gt;* A few small utility methods that probably no
&lt;br&gt;one has used have gone away, and a few better
&lt;br&gt;documented ones introduced.
&lt;br&gt;&lt;br&gt;Some of the main streamlining improvements rely on
&lt;br&gt;Java6 features. (It also runs of course on
&lt;br&gt;early-access versions of openjdk/jdk7.)
&lt;br&gt;There is no longer even internal guidance on
&lt;br&gt;how to adapt for Java5. If you must run on Java5, you
&lt;br&gt;probably want to keep using older snaphots.
&lt;br&gt;&lt;br&gt;Comments welcome as always. Things are in their usual places:
&lt;br&gt;API specs:
&lt;br&gt;&amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/&lt;/a&gt;&lt;br&gt;jar file:
&lt;br&gt;&amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166y.jar&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166y.jar&lt;/a&gt;&lt;br&gt;Browsable CVS sources:
&lt;br&gt;&amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166y/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166y/&lt;/a&gt;&lt;br&gt;&lt;br&gt;-Doug
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19347229&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/forkjoin-updates-tp19347229p19347229.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19282348</id>
	<title>tool for converting sequential code to use j.u.c.</title>
	<published>2008-09-02T19:58:15Z</published>
	<updated>2008-09-02T19:58:15Z</updated>
	<author>
		<name>Danny Dig-3</name>
	</author>
	<content type="html">Hello j.u.c. enthusiasts,
&lt;br&gt;&lt;br&gt;We've been working on a tool for reengineering Java sequential code for
&lt;br&gt;concurrency by using j.u.c. utilities.
&lt;br&gt;&lt;br&gt;We are announcing the first release of our tool, Concurrencer. It converts
&lt;br&gt;int fields to AtomicIntegers, and HashMap fields to ConcurrentHashMap.
&lt;br&gt;Concurrencer is implemented as an extension to Eclipse's refactoring engine.
&lt;br&gt;We've tried it on a few open-source projects and we found that (i) Concurrencer
&lt;br&gt;saves the programmer from changing many lines of code,
&lt;br&gt;(ii) is not error-prone like manual conversion, and (iii) is less
&lt;br&gt;omission-prone then
&lt;br&gt;the human.
&lt;br&gt;&lt;br&gt;We would love to get your feedback on the tool. Please use the tool and let us
&lt;br&gt;know if it is useful. We are looking for constructive criticism on how we can
&lt;br&gt;improve it.
&lt;br&gt;&lt;br&gt;Please visit the webpage below for instructions on how to get the tool. The
&lt;br&gt;webpage also contains a white paper (currently under review to a workshop)
&lt;br&gt;describing the features of Concurrencer. Due to lack of space, the paper
&lt;br&gt;does not contain many details like the data flow analysis for
&lt;br&gt;ConvertToConcurrentHashMap. It turns out that converting usages of put() to
&lt;br&gt;putIfAbsent() is not trivial, and has very interesting cases. Please try some
&lt;br&gt;variations yourself and let us know.
&lt;br&gt;&lt;br&gt;Here comes the webpage:
&lt;br&gt;&lt;a href=&quot;http://people.csail.mit.edu/dannydig/CR/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://people.csail.mit.edu/dannydig/CR/&lt;/a&gt;&lt;br&gt;&lt;br&gt;Currently we are implementing another transformation. It converts a recursive
&lt;br&gt;divide-and-conquer method into one which uses the FJTask framework and the
&lt;br&gt;RecursiveAction. We've tried it on a few textbook algorithms (e.g., fibonacci,
&lt;br&gt;quicksort, mergesort, matrix multiplication). We have not released yet this
&lt;br&gt;refactoring since it is not fully finished. Do you have some examples of real
&lt;br&gt;code which was converted to use RecursiveAction (other than the examples
&lt;br&gt;coming with forkjoin Javadoc)?
&lt;br&gt;&lt;br&gt;looking forward to receiving your feedback,
&lt;br&gt;Danny
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Danny Dig's homepage: &lt;a href=&quot;http://netfiles.uiuc.edu/dig/www&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://netfiles.uiuc.edu/dig/www&lt;/a&gt;&lt;br&gt;&lt;br&gt;Motto: &amp;quot;Success is not for the chosen few but for the few who choose&amp;quot;
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19282348&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/tool-for-converting-sequential-code-to-use-j.u.c.-tp19282348p19282348.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19265915</id>
	<title>Re: backport of java.util.concurrent: Bug in Arrays.deepEquals()</title>
	<published>2008-09-02T00:39:42Z</published>
	<updated>2008-09-02T00:39:42Z</updated>
	<author>
		<name>Dawid Kurzyniec-2</name>
	</author>
	<content type="html">+ concurrency-interest
&lt;br&gt;&lt;br&gt;Thanks! I'll look into it.
&lt;br&gt;&lt;br&gt;On Fri, Aug 29, 2008 at 11:30 AM, Philipp Buluschek
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19265915&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;philipp@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Dear Sir,
&lt;br&gt;&amp;gt; I am using your backport to the java.util.concurrent. (version 3.1 for java
&lt;br&gt;&amp;gt; 1.2)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In the package you distribute, there is also a backport for the
&lt;br&gt;&amp;gt; java.util.Arrays class, which is very handy. Unfortunately, I think that the
&lt;br&gt;&amp;gt; implementation of the deepEquals() method contains a bug. The following test
&lt;br&gt;&amp;gt; case should return true, while in the present implementation it returns
&lt;br&gt;&amp;gt; false. The present implementation in Sun's SDK 6.0 is correct in this
&lt;br&gt;&amp;gt; regard. Maybe you could update the packages to the implementation from Sun?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thank you again for your work in backporting the j.u.concurrent classes.
&lt;br&gt;&amp;gt; Best regards
&lt;br&gt;&amp;gt; Philipp Buluschek
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --- test case ---
&lt;br&gt;&amp;gt; import edu.emory.mathcs.backport.java.util.Arrays;
&lt;br&gt;&amp;gt; public class ArraysEqualsTest {
&lt;br&gt;&amp;gt; &amp;nbsp; public static void main(String[] args) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; float[][] f1 = {{1,2},{3.1415f, 2.7183f}};
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; float[][] f2 = {{1,2},{3.1415f, 2.7183f}};
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(Arrays.deepEquals(f1, f2)); // should return
&lt;br&gt;&amp;gt; true, but returns false
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; ________________________________________
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Philipp Buluschek, Dr-Ing. Dipl. EPFL
&lt;br&gt;&amp;gt; Software Design &amp; Implementation
&lt;br&gt;&amp;gt; Schellingstr. 16
&lt;br&gt;&amp;gt; D-80799 München, Germany
&lt;br&gt;&amp;gt; Phone: +49 89 2875 5533
&lt;br&gt;&amp;gt; Mobile: +49 157 7580 8218
&lt;br&gt;&amp;gt; E-mail: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19265915&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;philipp@...&lt;/a&gt;
&lt;br&gt;&amp;gt; ________________________________________
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19265915&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Re%3A-backport-of-java.util.concurrent%3A-Bug-in-Arrays.deepEquals%28%29-tp19265915p19265915.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19199705</id>
	<title>Re: Learning Java.util.concurrent</title>
	<published>2008-08-28T04:57:54Z</published>
	<updated>2008-08-28T04:57:54Z</updated>
	<author>
		<name>Peter Veentjer</name>
	</author>
	<content type="html">The fork join stuff in Java is not yet final, and not described in any
&lt;br&gt;books (implementation still is subject to change).
&lt;br&gt;&lt;br&gt;On the IBM site there are some articles about it written by Brian Goetz:
&lt;br&gt;&lt;a href=&quot;http://www.ibm.com/developerworks/java/library/j-jtp11137.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ibm.com/developerworks/java/library/j-jtp11137.html&lt;/a&gt;&lt;br&gt;&lt;a href=&quot;http://www.ibm.com/developerworks/java/library/j-jtp03048.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ibm.com/developerworks/java/library/j-jtp03048.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;And there also is a paper about the fork join framework you could study:
&lt;br&gt;&lt;a href=&quot;http://gee.cs.oswego.edu/dl/papers/fj.pdf&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gee.cs.oswego.edu/dl/papers/fj.pdf&lt;/a&gt;&lt;br&gt;&lt;br&gt;But I don't know how much it is in sync with the current
&lt;br&gt;implementation.But it is very informative anyway.
&lt;br&gt;&lt;br&gt;You could also check out the Intel thread building blocks:
&lt;br&gt;&lt;a href=&quot;http://www.amazon.com/Intel-Threading-Building-Blocks-Parallelism/dp/0596514808/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219923968&amp;sr=8-1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Intel-Threading-Building-Blocks-Parallelism/dp/0596514808/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219923968&amp;sr=8-1&lt;/a&gt;&lt;br&gt;There is a lot of overlap in both libraries and it never hurts to look
&lt;br&gt;at fork join problems using different glasses.
&lt;br&gt;&lt;br&gt;For a more general approach you could also check out:
&lt;br&gt;&lt;a href=&quot;http://www.amazon.com/Patterns-Parallel-Programming-Software/dp/0321228111/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219924058&amp;sr=1-1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Patterns-Parallel-Programming-Software/dp/0321228111/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219924058&amp;sr=1-1&lt;/a&gt;&lt;br&gt;It describes the fork join pattern and a lot of other patterns related
&lt;br&gt;to parallel programming.
&lt;br&gt;&lt;br&gt;And for concurrency in Java the following books are my favorites:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219924258&amp;sr=1-1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219924258&amp;sr=1-1&lt;/a&gt;&lt;br&gt;Very practical and describes the stuff introduced in Java 5.
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.amazon.com/Concurrent-Programming-Java-TM-Principles/dp/0201310090/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219924428&amp;sr=1-1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Concurrent-Programming-Java-TM-Principles/dp/0201310090/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1219924428&amp;sr=1-1&lt;/a&gt;&lt;br&gt;A classic book. Even though it is almost 10 years old, it is still
&lt;br&gt;very valuable.
&lt;br&gt;&lt;br&gt;Both books complement each other.. one is more practical.. and the
&lt;br&gt;other is more theoretical. And to do concurrency control well, you
&lt;br&gt;need to be educated in both areas.
&lt;br&gt;&lt;br&gt;On Thu, Aug 28, 2008 at 8:54 AM, Ganesh Bikshandi &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19199705&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gbikshan@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Dear Members,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I want to learn about java.util.concurrent. Which is the best source? If
&lt;br&gt;&amp;gt; there is a text book, that will be of great use. &amp;nbsp;Especially, I want to
&lt;br&gt;&amp;gt; lear about the fork-join stuff.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Best Regards,
&lt;br&gt;&amp;gt; Ganesh
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; Concurrency-interest mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19199705&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19199705&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Learning--Java.util.concurrent-tp19195472p19199705.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19195472</id>
	<title>Learning  Java.util.concurrent</title>
	<published>2008-08-27T23:54:38Z</published>
	<updated>2008-08-27T23:54:38Z</updated>
	<author>
		<name>Ganesh Bikshandi-2</name>
	</author>
	<content type="html">&lt;br&gt;Dear Members,
&lt;br&gt;&lt;br&gt;I want to learn about java.util.concurrent. Which is the best source? If
&lt;br&gt;there is a text book, that will be of great use. &amp;nbsp;Especially, I want to
&lt;br&gt;lear about the fork-join stuff.
&lt;br&gt;&lt;br&gt;Best Regards,
&lt;br&gt;Ganesh
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19195472&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Learning--Java.util.concurrent-tp19195472p19195472.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19164203</id>
	<title>Re: FJ usage question: Mutable procedures</title>
	<published>2008-08-26T07:53:38Z</published>
	<updated>2008-08-26T07:53:38Z</updated>
	<author>
		<name>David J. Biesack</name>
	</author>
	<content type="html">&lt;br&gt;Thanks, a raw RecursiveAction does the trick for me for now.
&lt;br&gt;&lt;br&gt;Note: there are two bugs in the examples &lt;a href=&quot;http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/RecursiveAction.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/RecursiveAction.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;In the sumOfSquares example, the compute() method iterates while i &amp;lt; h :
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (int i = l; i &amp;lt; h; ++i) // perform leftmost base step
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sum += array[i] * array[i];
&lt;br&gt;&lt;br&gt;Thus, the constructor call 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Applyer a = new Applyer(array, 0, n-1, seqSize, null);
&lt;br&gt;&lt;br&gt;should not subtract one from n:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Applyer a = new Applyer(array, 0, n, seqSize, null);
&lt;br&gt;&lt;br&gt;Also, in Applyer in the javadoc
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;int result; 
&lt;br&gt;&lt;br&gt;should be 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;double result;
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Date: Tue, 26 Aug 2008 08:59:59 -0400
&lt;br&gt;&amp;gt; From: Doug Lea &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19164203&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dl@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt; CC: &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19164203&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;concurrency-interest@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; David J. Biesack wrote:
&lt;br&gt;&amp;gt; &amp;gt; ParallelDoubleArray has a summary() method; but it's not implemented in
&lt;br&gt;&amp;gt; &amp;gt; terms of the public apply/Ops.DoubleProcedure API of
&lt;br&gt;&amp;gt; &amp;gt; ParallelDoubleArray. I'd like to make that more general and define a
&lt;br&gt;&amp;gt; &amp;gt; Ops.DoubleProcedure to compute extended summary statistics, or perform
&lt;br&gt;&amp;gt; &amp;gt; other operations which require updating state within the ops/procedures.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; This is one of the basic tradeoffs made in ParallelArray:
&lt;br&gt;&amp;gt; It knows how to translate fixed families of array operations
&lt;br&gt;&amp;gt; into underlying fork/join processing. While we can and should
&lt;br&gt;&amp;gt; keep adding to this family (as in supporting indexed procedures),
&lt;br&gt;&amp;gt; there will always only be a finite set of functional/procedural
&lt;br&gt;&amp;gt; forms that it understands.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; When you need to go beyond them, the best recourse is to
&lt;br&gt;&amp;gt; step into the fun world of direct fork/join programming.
&lt;br&gt;&amp;gt; Often, it is fairly straightforward, as in the examples
&lt;br&gt;&amp;gt; (with more to come) in the RecursiveAction etc javadoc.
&lt;br&gt;&amp;gt; ParallelArray includes a bunch of tweaks that improve
&lt;br&gt;&amp;gt; performance over the basic templates (which it needs
&lt;br&gt;&amp;gt; in part because it must act without any programmer
&lt;br&gt;&amp;gt; supplied granularity information). The next update
&lt;br&gt;&amp;gt; (real soon now) will include documented, exposed
&lt;br&gt;&amp;gt; methods and classes that allow others to use them too,
&lt;br&gt;&amp;gt; but most of these can be ignored in everyday programming.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -Doug
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David J. Biesack &amp;nbsp; &amp;nbsp; SAS Institute Inc.
&lt;br&gt;(919) 531-7771 &amp;nbsp; &amp;nbsp; &amp;nbsp; SAS Campus Drive
&lt;br&gt;&lt;a href=&quot;http://www.sas.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.sas.com&lt;/a&gt;&amp;nbsp; &amp;nbsp;Cary, NC 27513
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19164203&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/FJ-usage-question%3A-Mutable-procedures-tp19151003p19164203.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19162478</id>
	<title>Re: FJ usage question: Mutable procedures</title>
	<published>2008-08-26T05:59:59Z</published>
	<updated>2008-08-26T05:59:59Z</updated>
	<author>
		<name>Doug Lea</name>
	</author>
	<content type="html">David J. Biesack wrote:
&lt;br&gt;&amp;gt; ParallelDoubleArray has a summary() method; but it's not implemented in
&lt;br&gt;&amp;gt; terms of the public apply/Ops.DoubleProcedure API of
&lt;br&gt;&amp;gt; ParallelDoubleArray. I'd like to make that more general and define a
&lt;br&gt;&amp;gt; Ops.DoubleProcedure to compute extended summary statistics, or perform
&lt;br&gt;&amp;gt; other operations which require updating state within the ops/procedures.
&lt;br&gt;&lt;br&gt;This is one of the basic tradeoffs made in ParallelArray:
&lt;br&gt;It knows how to translate fixed families of array operations
&lt;br&gt;into underlying fork/join processing. While we can and should
&lt;br&gt;keep adding to this family (as in supporting indexed procedures),
&lt;br&gt;there will always only be a finite set of functional/procedural
&lt;br&gt;forms that it understands.
&lt;br&gt;&lt;br&gt;When you need to go beyond them, the best recourse is to
&lt;br&gt;step into the fun world of direct fork/join programming.
&lt;br&gt;Often, it is fairly straightforward, as in the examples
&lt;br&gt;(with more to come) in the RecursiveAction etc javadoc.
&lt;br&gt;ParallelArray includes a bunch of tweaks that improve
&lt;br&gt;performance over the basic templates (which it needs
&lt;br&gt;in part because it must act without any programmer
&lt;br&gt;supplied granularity information). The next update
&lt;br&gt;(real soon now) will include documented, exposed
&lt;br&gt;methods and classes that allow others to use them too,
&lt;br&gt;but most of these can be ignored in everyday programming.
&lt;br&gt;&lt;br&gt;-Doug
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19162478&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/FJ-usage-question%3A-Mutable-procedures-tp19151003p19162478.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19151003</id>
	<title>FJ usage question: Mutable procedures</title>
	<published>2008-08-25T12:59:36Z</published>
	<updated>2008-08-25T12:59:36Z</updated>
	<author>
		<name>David J. Biesack</name>
	</author>
	<content type="html">&lt;br&gt;ParallelDoubleArray has a summary() method; but it's not implemented in
&lt;br&gt;terms of the public apply/Ops.DoubleProcedure API of
&lt;br&gt;ParallelDoubleArray. I'd like to make that more general and define a
&lt;br&gt;Ops.DoubleProcedure to compute extended summary statistics, or perform
&lt;br&gt;other operations which require updating state within the ops/procedures.
&lt;br&gt;As noted earlier, there is no IntAndDoubleProcedure, so I'm using a
&lt;br&gt;mutable Ops.IntAndDoubleToDouble instead
&lt;br&gt;&lt;br&gt;Naturally, I must add a lock around the mutating portions of the class
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; @Override
&lt;br&gt;&amp;nbsp; &amp;nbsp; public double op(final int index, final double a) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // System.out.println(a);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!Double.isNaN(a)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized (this) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum += a;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sumOfSquares += (a * a);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n++;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (a &amp;gt; max) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; max = a;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; maxIndex = index;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (a &amp;lt; min) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min = a;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; minIndex = index;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return a;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;However, the PAS.FJDStats does not use synchronization but rather
&lt;br&gt;creates new instances during the divide/conquer algorithms, and thus no
&lt;br&gt;race conditions.
&lt;br&gt;&lt;br&gt;However, I don't see where this divide/conquer approach is part of the
&lt;br&gt;public ParallelArray API; PAS and its kin are not public.
&lt;br&gt;&lt;br&gt;I would like to be able to do the divide/conquer for general purpose
&lt;br&gt;mutable procedures/mappings. Is this possible? Another more simplistic
&lt;br&gt;option would be to use ex.getParallelismLevel() and be able to create an
&lt;br&gt;array of procedures/mappers, each of which the framework guarantees
&lt;br&gt;safe, non-blocking execution
&lt;br&gt;&lt;br&gt;&amp;nbsp; Ops.DoubleProcedure procedures[] = new MyProcedure[ex.getParallelismLevel()];
&lt;br&gt;&amp;nbsp; // initialize
&lt;br&gt;&amp;nbsp; parallelArray.apply(procedures);
&lt;br&gt;&lt;br&gt;after which I can run a reducer over that array to combine their
&lt;br&gt;intermediate results.
&lt;br&gt;&lt;br&gt;Or, are there better ways to achieve these goals?
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David J. Biesack &amp;nbsp; &amp;nbsp; SAS Institute Inc.
&lt;br&gt;(919) 531-7771 &amp;nbsp; &amp;nbsp; &amp;nbsp; SAS Campus Drive
&lt;br&gt;&lt;a href=&quot;http://www.sas.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.sas.com&lt;/a&gt;&amp;nbsp; &amp;nbsp;Cary, NC 27513
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19151003&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/FJ-usage-question%3A-Mutable-procedures-tp19151003p19151003.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19074921</id>
	<title>Cost of Inserting bytecodes around monitorenter and monitorexit</title>
	<published>2008-08-20T10:21:20Z</published>
	<updated>2008-08-20T10:21:20Z</updated>
	<author>
		<name>Aaron Greenhouse</name>
	</author>
	<content type="html">(Sorry this is a long message.)
&lt;br&gt;&lt;br&gt;Hi everyone. &amp;nbsp;I have a question/problem that is a bit off topic, but I
&lt;br&gt;need the advice of those who understand synchronization and the JVM
&lt;br&gt;intimately. &amp;nbsp;I am manipulating Java classfiles (using ASM) as part of a
&lt;br&gt;profiling project. &amp;nbsp;I was trying to understand the overhead created by
&lt;br&gt;the inserted bytecodes, and I was surprised to see how much overhead I
&lt;br&gt;have when I instrument around monitorenter and monitorexit operations.
&lt;br&gt;Primarily my inserted bytecodes set up method calls to a data collection
&lt;br&gt;class. &amp;nbsp;I insert a method call before and after monitorenter and after
&lt;br&gt;moniterexit. &amp;nbsp;In this case, I have subsituted a data collection class
&lt;br&gt;that has empty methods.
&lt;br&gt;&lt;br&gt;I am concerned because on my test case, the unintrumented program runs
&lt;br&gt;in under 4 minutes. &amp;nbsp;If I instrument only monitorenter and monitorexit
&lt;br&gt;bytecodes, the program takes over 20 minutes to run. &amp;nbsp;Before you tell me
&lt;br&gt;that it is the inserted method calls that cause the problem, let me say
&lt;br&gt;this: If I instead instrument only method calls which also causes 3
&lt;br&gt;additional methods to be called for each original method call, the &amp;nbsp;
&lt;br&gt;entire
&lt;br&gt;program runs in around 5 minutes. &amp;nbsp;So I think there is something very
&lt;br&gt;strange going on related to synchronization.
&lt;br&gt;&lt;br&gt;To be more specific, I have created a simpler test class. This class
&lt;br&gt;doesn't do anything useful. &amp;nbsp;It is just designed to exercise a bunch of
&lt;br&gt;synchronized blocks. &amp;nbsp;All the important stuff is in the Shared class.
&lt;br&gt;&lt;br&gt;public class Main {
&lt;br&gt;&amp;nbsp; &amp;nbsp;public static void main(final String[] args) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&amp;quot;Main&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final Shared s = new Shared();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final Thread threadA = new Thread(new A(s));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final Thread threadB = new Thread(new B(s));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final long startTime = System.currentTimeMillis();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;threadA.start();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;threadB.start();
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while (threadA.isAlive() &amp;&amp; threadB.isAlive()) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;threadA.join();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;threadB.join();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} catch (final InterruptedException e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// won't happen
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final long endTime = System.currentTimeMillis();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final long time = endTime - startTime;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&amp;quot;Done in &amp;quot; + time + &amp;quot;ms (&amp;quot; + ((time/1000.0)/ 
&lt;br&gt;60.0) + &amp;quot; minutes)&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;class A implements Runnable {
&lt;br&gt;&amp;nbsp; &amp;nbsp;private static final int START = 2500000;
&lt;br&gt;&amp;nbsp; &amp;nbsp;private Shared s;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public A(final Shared s) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.s = s;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;s.forB(START);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void run() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while (true) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;final int v = s.fromB();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (v &amp;lt;= 0) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;s.forB(v);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;s.forB(v+1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} catch(final InterruptedException e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// won't happen
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;class B implements Runnable {
&lt;br&gt;&amp;nbsp; &amp;nbsp;private Shared s;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public B(final Shared s) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.s = s;
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void run() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while (true) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;final int v = s.fromA();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (v &amp;lt;= 0) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;s.forA(v);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;s.forA(v-2);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} catch (final InterruptedException e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// won't happen
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;class Shared {
&lt;br&gt;&amp;nbsp; &amp;nbsp;private boolean hasForB = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromAforB;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private boolean hasForA = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromBforA;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void forB(final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;forB_impl(this, v);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forB_impl(final Object lock, final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fromAforB = v;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForB = true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.notifyAll();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void forA(final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;forA_impl(this, v);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forA_impl(final Object lock, final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fromBforA = v;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForA = true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.notifyAll();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public int fromB() throws InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return fromB_impl(this);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromB_impl(final Object lock) throws &amp;nbsp;
&lt;br&gt;InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while (!hasForA) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.wait();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForA = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return fromBforA;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public int fromA() throws InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return fromA_impl(this);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromA_impl(final Object lock) throws &amp;nbsp;
&lt;br&gt;InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while (!hasForB) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.wait();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForB = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return fromAforB;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;The Shared class is using an extra layer of delegation because I was
&lt;br&gt;trying to prevent the Java and JIT compilers from taking advantage of
&lt;br&gt;the fact that the lock is known to be the receiver; this is important
&lt;br&gt;below.
&lt;br&gt;&lt;br&gt;When I run this class normally on my Intel Core 2 Duo iMac, under Java
&lt;br&gt;5, it takes about 33 seconds. &amp;nbsp;When I run with instrumentation added
&lt;br&gt;around each monitorenter and monitorexit bytecode, it runs in about 39
&lt;br&gt;seconds. &amp;nbsp;I have similar (but slower) results on an older Intel Dell
&lt;br&gt;Laptop running Java 6.
&lt;br&gt;&lt;br&gt;Now, here is where it gets very strange. &amp;nbsp;I created a version of the
&lt;br&gt;Shared class that approximates very closely the instrumentation that is
&lt;br&gt;being added in the bytecode:
&lt;br&gt;&lt;br&gt;class Shared {
&lt;br&gt;&amp;nbsp; &amp;nbsp;private boolean hasForB = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromAforB;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private boolean hasForA = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromBforA;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void forB(final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;forB_impl(this, v);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forB_impl(final Object lock, final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.beforeStart(lock, lock == this, lock == Shared.class, &amp;nbsp;
&lt;br&gt;Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterStart(lock, Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fromAforB = v;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForB = true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.notifyAll();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;} finally {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterEnd(this, Shared.class, 10);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void forA(final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;forA_impl(this, v);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forA_impl(final Object lock, final int v) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.beforeStart(lock, lock == this, lock == Shared.class, &amp;nbsp;
&lt;br&gt;Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterStart(lock, Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fromBforA = v;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForA = true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.notifyAll();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;} finally {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterEnd(this, Shared.class, 10);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public int fromB() throws InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return fromB_impl(this);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromB_impl(final Object lock) throws &amp;nbsp;
&lt;br&gt;InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.beforeStart(lock, lock == this, lock == Shared.class, &amp;nbsp;
&lt;br&gt;Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterStart(lock, Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while (!hasForA) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.wait();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForA = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return fromBforA;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;} finally {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterEnd(this, Shared.class, 10);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public int fromA() throws InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return fromA_impl(this);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;private int fromA_impl(final Object lock) throws &amp;nbsp;
&lt;br&gt;InterruptedException {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.beforeStart(lock, lock == this, lock == Shared.class, &amp;nbsp;
&lt;br&gt;Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (lock) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterStart(lock, Shared.class, 1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while (!hasForB) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lock.wait();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hasForB = false;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return fromAforB;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;} finally {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Store.afterEnd(this, Shared.class, 10);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;class Store {
&lt;br&gt;&amp;nbsp; &amp;nbsp;public static void beforeStart(
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;final Object o, final boolean a, final boolean b, Class c, int &amp;nbsp;
&lt;br&gt;l) {}
&lt;br&gt;&amp;nbsp; &amp;nbsp;public static void afterStart(final Object o, Class c, int l) {}
&lt;br&gt;&amp;nbsp; &amp;nbsp;public static void afterEnd(final Object o, Class c, int l) {}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;This is where I want to avoid taking advantage of the fact that the lock
&lt;br&gt;is the receiver. &amp;nbsp;Obviously, this isn't going to be exactly the same as
&lt;br&gt;the instrumented bytecode, because the bytecode manipulator doens't know
&lt;br&gt;what operations preceeded the monitorenter or monitorexit operations and
&lt;br&gt;has to do some possibly redundant swap and dup stack manipulations. &amp;nbsp;But
&lt;br&gt;it's pretty close. &amp;nbsp;When I run this version, it completes in about 33
&lt;br&gt;seconds. &amp;nbsp;Actually, sometimes it seems to be slightly faster than the
&lt;br&gt;original, running in 32 seconds.
&lt;br&gt;&lt;br&gt;This doesn't make any sense to me. &amp;nbsp;Other instrumentation that I insert
&lt;br&gt;uses swap and dup, and is not heavily penalized. &amp;nbsp;I actually rewrote the
&lt;br&gt;transformation to use local variables to avoid the use of swaps and
&lt;br&gt;dups, but that turned out to be even slower!
&lt;br&gt;&lt;br&gt;To be even more specific again, here is the bytecode for the forB_impl()
&lt;br&gt;method for the different versions. &amp;nbsp;(All the other methods are similar).
&lt;br&gt;&lt;br&gt;Original Method
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;// Method descriptor #29 (Ljava/lang/Object;I)V
&lt;br&gt;&amp;nbsp; &amp;nbsp;// Stack: 2, Locals: 4
&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forB_impl(java.lang.Object lock, int v);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp;astore_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp;monitorenter
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp;iload_2 [v]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp;putfield test.Shared.fromAforB : int [31]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 9 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;11 &amp;nbsp;putfield test.Shared.hasForB : boolean [16]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;14 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp;invokevirtual java.lang.Object.notifyAll() : void [33]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp;aload_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;19 &amp;nbsp;monitorexit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;20 &amp;nbsp;goto 26
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;23 &amp;nbsp;aload_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;24 &amp;nbsp;monitorexit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp;athrow
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;26 &amp;nbsp;return
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exception Table:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 4, pc: 20] -&amp;gt; 23 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 23, pc: 25] -&amp;gt; 23 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Line numbers:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, line: 15]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 4, line: 16]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 9, line: 17]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 14, line: 18]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 18, line: 15]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 26, line: 20]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Local variable table:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 27] local: this index: 0 type: test.Shared
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 27] local: lock index: 1 type: java.lang.Object
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 27] local: v index: 2 type: int
&lt;br&gt;&lt;br&gt;Pseudo-Instrumented Method
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;// Method descriptor #29 (Ljava/lang/Object;I)V
&lt;br&gt;&amp;nbsp; &amp;nbsp;// Stack: 5, Locals: 5
&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forB_impl(java.lang.Object lock, int v);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp;if_acmpne 10
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 7 &amp;nbsp;goto 11
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp;iconst_0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;11 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;12 &amp;nbsp;ldc &amp;lt;Class testInst.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;14 &amp;nbsp;if_acmpne 21
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;17 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;18 &amp;nbsp;goto 22
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;21 &amp;nbsp;iconst_0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;22 &amp;nbsp;ldc &amp;lt;Class testInst.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;24 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp;invokestatic testInst.Store.beforeStart(java.lang.Object, &amp;nbsp;
&lt;br&gt;boolean, boolean, java.lang.Class, int) : void [31]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;28 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;29 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;30 &amp;nbsp;astore_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;31 &amp;nbsp;monitorenter
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;32 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;33 &amp;nbsp;ldc &amp;lt;Class testInst.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;35 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;36 &amp;nbsp;invokestatic testInst.Store.afterStart(java.lang.Object, &amp;nbsp;
&lt;br&gt;java.lang.Class, int) : void [37]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;39 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;40 &amp;nbsp;iload_2 [v]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;41 &amp;nbsp;putfield testInst.Shared.fromAforB : int [41]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;44 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;45 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;46 &amp;nbsp;putfield testInst.Shared.hasForB : boolean [16]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;49 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;50 &amp;nbsp;invokevirtual java.lang.Object.notifyAll() : void [43]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;53 &amp;nbsp;aload_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;54 &amp;nbsp;monitorexit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;55 &amp;nbsp;goto 74
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;58 &amp;nbsp;aload_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;59 &amp;nbsp;monitorexit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;60 &amp;nbsp;athrow
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;61 &amp;nbsp;astore 4
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;63 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;64 &amp;nbsp;ldc &amp;lt;Class testInst.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;66 &amp;nbsp;bipush 10
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;68 &amp;nbsp;invokestatic testInst.Store.afterEnd(java.lang.Object, &amp;nbsp;
&lt;br&gt;java.lang.Class, int) : void [46]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;71 &amp;nbsp;aload 4
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;73 &amp;nbsp;athrow
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;74 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;75 &amp;nbsp;ldc &amp;lt;Class testInst.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;77 &amp;nbsp;bipush 10
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;79 &amp;nbsp;invokestatic testInst.Store.afterEnd(java.lang.Object, &amp;nbsp;
&lt;br&gt;java.lang.Class, int) : void [46]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;82 &amp;nbsp;return
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exception Table:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 32, pc: 55] -&amp;gt; 58 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 58, pc: 60] -&amp;gt; 58 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 61] -&amp;gt; 61 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Line numbers:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, line: 16]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 28, line: 17]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 32, line: 18]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 39, line: 19]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 44, line: 20]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 49, line: 21]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 53, line: 17]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 61, line: 23]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 63, line: 24]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 71, line: 25]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 74, line: 24]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 82, line: 26]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Local variable table:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 83] local: this index: 0 type: testInst.Shared
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 83] local: lock index: 1 type: java.lang.Object
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 83] local: v index: 2 type: int
&lt;br&gt;&lt;br&gt;Instrumented Method
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;// Method descriptor #29 (Ljava/lang/Object;I)V
&lt;br&gt;&amp;nbsp; &amp;nbsp;// Stack: 9, Locals: 4
&lt;br&gt;&amp;nbsp; &amp;nbsp;private void forB_impl(java.lang.Object lock, int v);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp;astore_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp;ldc &amp;lt;Class test.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 7 &amp;nbsp;dup_x2
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 8 &amp;nbsp;swap
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 9 &amp;nbsp;dup_x1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;11 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;12 &amp;nbsp;if_acmpne 19
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;16 &amp;nbsp;goto 20
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;19 &amp;nbsp;iconst_0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;20 &amp;nbsp;dup_x2
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;21 &amp;nbsp;pop
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;22 &amp;nbsp;swap
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;23 &amp;nbsp;dup_x1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;24 &amp;nbsp;if_acmpne 31
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;27 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;28 &amp;nbsp;goto 32
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;31 &amp;nbsp;iconst_0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;32 &amp;nbsp;swap
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;33 &amp;nbsp;bipush 15
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;35 &amp;nbsp;invokestatic &amp;nbsp;
&lt;br&gt;com.surelogic._flashlight.rewriter.test.EmptyStore.beforeIntrinsicLockAc 
&lt;br&gt;quisition(java.lang.Object, boolean, boolean, java.lang.Class, int) : &amp;nbsp;
&lt;br&gt;void [67]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;38 &amp;nbsp;monitorenter
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;39 &amp;nbsp;bipush 15
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;41 &amp;nbsp;invokestatic &amp;nbsp;
&lt;br&gt;com.surelogic._flashlight.rewriter.test.EmptyStore.afterIntrinsicLockAcq 
&lt;br&gt;uisition(java.lang.Object, java.lang.Class, int) : void [71]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;44 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;45 &amp;nbsp;iload_2 [v]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;46 &amp;nbsp;putfield test.Shared.fromAforB : int [31]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;49 &amp;nbsp;aload_0 [this]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;50 &amp;nbsp;iconst_1
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;51 &amp;nbsp;putfield test.Shared.hasForB : boolean [16]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;54 &amp;nbsp;aload_1 [lock]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;55 &amp;nbsp;invokevirtual java.lang.Object.notifyAll() : void [33]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;58 &amp;nbsp;aload_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;59 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;60 &amp;nbsp;monitorexit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;61 &amp;nbsp;ldc &amp;lt;Class test.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;63 &amp;nbsp;bipush 15
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;65 &amp;nbsp;invokestatic &amp;nbsp;
&lt;br&gt;com.surelogic._flashlight.rewriter.test.EmptyStore.afterIntrinsicLockRel 
&lt;br&gt;ease(java.lang.Object, java.lang.Class, int) : void [74]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;68 &amp;nbsp;goto 82
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;71 &amp;nbsp;aload_3
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;72 &amp;nbsp;dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;73 &amp;nbsp;monitorexit
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;74 &amp;nbsp;ldc &amp;lt;Class test.Shared&amp;gt; [1]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;76 &amp;nbsp;bipush 15
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;78 &amp;nbsp;invokestatic &amp;nbsp;
&lt;br&gt;com.surelogic._flashlight.rewriter.test.EmptyStore.afterIntrinsicLockRel 
&lt;br&gt;ease(java.lang.Object, java.lang.Class, int) : void [74]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;81 &amp;nbsp;athrow
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;82 &amp;nbsp;return
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exception Table:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 44, pc: 68] -&amp;gt; 71 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 71, pc: 81] -&amp;gt; 71 when : any
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Line numbers:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, line: 15]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 44, line: 16]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 49, line: 17]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 54, line: 18]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 58, line: 15]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 82, line: 20]
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Local variable table:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 83] local: this index: 0 type: test.Shared
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 83] local: lock index: 1 type: java.lang.Object
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[pc: 0, pc: 83] local: v index: 2 type: int
&lt;br&gt;&lt;br&gt;In summary, I am completely stumped as to why there is a performance
&lt;br&gt;difference between my bytecode-instrumented class (33 seconds) and my
&lt;br&gt;Java-instrumented version (39 seconds). &amp;nbsp;Is the JIT doing something that
&lt;br&gt;I'm not aware of? &amp;nbsp;Am I running into somekind of weird memory effect?
&lt;br&gt;Can someone please shed some light on this situation?
&lt;br&gt;&lt;br&gt;--Aaron
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19074921&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Cost-of-Inserting-bytecodes-around-monitorenter-and-monitorexit-tp19074921p19074921.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19039035</id>
	<title>Re: jsr166y IndexedProcedure ?</title>
	<published>2008-08-18T12:40:55Z</published>
	<updated>2008-08-18T12:40:55Z</updated>
	<author>
		<name>Doug Lea</name>
	</author>
	<content type="html">David J. Biesack wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Back in January, there was some discussion of the jsr166y
&lt;br&gt;&amp;gt; forkjoin/ParallelArray API. I had proposed the ability to pass the
&lt;br&gt;&amp;gt; element index to the procedure via a ParallelArray.apply. Doug replied
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;quot;... the lack of an indexed-procedure version of apply is
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;a bug; thanks for pointing it out! This will be added.&amp;quot;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I've hit another case where this would be useful, so I'm just checking the status
&lt;br&gt;&amp;gt; of any API changes along these lines.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;Still on the todo list. Sorry for the long delay. I've been
&lt;br&gt;revamping some of the underlying FJ mechanics to provide
&lt;br&gt;better support for extended capabilities (phasers, new forms
&lt;br&gt;of Async tasks etc) that also invite use of some better algorithms
&lt;br&gt;underlying ParallelArray. All this needs to come together a
&lt;br&gt;bit more before checkin/release. Hopefully within a week or
&lt;br&gt;so, followed soon after by business-as-usual improvements like
&lt;br&gt;this one.
&lt;br&gt;&lt;br&gt;-Doug
&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19039035&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/jsr166y-IndexedProcedure---tp19037814p19039035.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19037814</id>
	<title>jsr166y IndexedProcedure ?</title>
	<published>2008-08-18T11:32:20Z</published>
	<updated>2008-08-18T11:32:20Z</updated>
	<author>
		<name>David J. Biesack</name>
	</author>
	<content type="html">&lt;br&gt;Back in January, there was some discussion of the jsr166y
&lt;br&gt;forkjoin/ParallelArray API. I had proposed the ability to pass the
&lt;br&gt;element index to the procedure via a ParallelArray.apply. Doug replied
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;quot;... the lack of an indexed-procedure version of apply is
&lt;br&gt;&amp;nbsp; &amp;nbsp;a bug; thanks for pointing it out! This will be added.&amp;quot;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &lt;a href=&quot;http://cs.oswego.edu/pipermail/concurrency-interest/2008-January/004917.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/pipermail/concurrency-interest/2008-January/004917.html&lt;/a&gt;&lt;br&gt;&amp;nbsp; &lt;a href=&quot;http://cs.oswego.edu/pipermail/concurrency-interest/2008-January/004922.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/pipermail/concurrency-interest/2008-January/004922.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;I've hit another case where this would be useful, so I'm just checking the status
&lt;br&gt;of any API changes along these lines.
&lt;br&gt;&lt;br&gt;My use case: implementing ParallelDoubleArray.SummaryStatistics
&lt;br&gt;and similar behaviors which do not mutate the ParallelDoubleArray.
&lt;br&gt;&lt;br&gt;I can't use summary() because I want new behavior: additional statistics
&lt;br&gt;like variance and standard deviation, and pluggable value filtering;
&lt;br&gt;i.e. do not include NaNs in size/sum/min/max/average.
&lt;br&gt;&lt;br&gt;I can't use a DoubleProcedure because I need the item index in order to
&lt;br&gt;implement minIndex() and maxIndex().
&lt;br&gt;&lt;br&gt;I can use pda.replaceWithMappedIndex(Ops.IntAndDoubleToDouble) but that
&lt;br&gt;performs extra work of assigning elements which I don't need. I'd like
&lt;br&gt;to be able to reason about immutability, and replace* methods prevents
&lt;br&gt;that.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David J. Biesack &amp;nbsp; &amp;nbsp; SAS Institute Inc.
&lt;br&gt;(919) 531-7771 &amp;nbsp; &amp;nbsp; &amp;nbsp; SAS Campus Drive
&lt;br&gt;&lt;a href=&quot;http://www.sas.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.sas.com&lt;/a&gt;&amp;nbsp; &amp;nbsp;Cary, NC 27513
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19037814&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/jsr166y-IndexedProcedure---tp19037814p19037814.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19014320</id>
	<title>Re: ThreadPoolExecutor corePoolSize incompatibility between backport and j.u.c.</title>
	<published>2008-08-16T11:59:17Z</published>
	<updated>2008-08-16T11:59:17Z</updated>
	<author>
		<name>Ben Manes</name>
	</author>
	<content type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div style=&quot;font-family:times new roman,new york,times,serif;font-size:10pt&quot;&gt;&lt;div style=&quot;font-family: times new roman,new york,times,serif; font-size: 10pt;&quot;&gt;It is in the JavaDoc.&amp;nbsp; Setting the core size to 1 only fixed the problem by making one thread available, but it will never grow.&amp;nbsp; If you really want this behavior, there are tricks to do it.&lt;br&gt;&lt;br&gt;---&lt;br&gt;&lt;br&gt;Core and maximum pool sizes&lt;br&gt;A ThreadPoolExecutor will automatically adjust the pool size (see getPoolSize()) according to the bounds set by corePoolSize (see getCorePoolSize()) and maximumPoolSize (see getMaximumPoolSize()). When a new task is submitted in method execute(java.lang.Runnable), and fewer than corePoolSize threads are running, a new thread is created to handle the request, even if other worker threads are idle. If there are more than corePoolSize but less than maximumPoolSize threads
 running, a new thread will be created only if the queue is full. By setting corePoolSize and maximumPoolSize the same, you create a fixed-size thread pool. By setting maximumPoolSize to an essentially unbounded value such as Integer.MAX_VALUE, you allow the pool to accommodate an arbitrary number of concurrent tasks. Most typically, core and maximum pool sizes are set only upon construction, but they may also be changed dynamically using setCorePoolSize(int) and setMaximumPoolSize(int).&lt;br&gt;&lt;br&gt;Unbounded queues. Using an unbounded queue (for example a LinkedBlockingQueue without a predefined capacity) will cause new tasks to be queued in cases where all corePoolSize threads are busy. Thus, no more than corePoolSize threads will ever be created. (And the value of the maximumPoolSize therefore doesn't have any effect.) This may be appropriate when each task is completely independent of others, so tasks cannot affect each others execution; for example, in a
 web page server. While this style of queuing can be useful in smoothing out transient bursts of requests, it admits the possibility of unbounded work queue growth when commands continue to arrive on average faster than they can be processed.&lt;br&gt;&lt;br&gt;&lt;div style=&quot;font-family: times new roman,new york,times,serif; font-size: 12pt;&quot;&gt;----- Original Message ----&lt;br&gt;From: Greg Luck &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19014320&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gluck@...&lt;/a&gt;&amp;gt;&lt;br&gt;To: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19014320&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;concurrency-interest@...&lt;/a&gt;&lt;br&gt;Sent: Saturday, August 16, 2008 4:54:53 AM&lt;br&gt;Subject: [concurrency-interest] ThreadPoolExecutor corePoolSize incompatibility between backport and j.u.c.&lt;br&gt;&lt;br&gt;
&lt;div&gt;I am looking at moving the new version of ehcache to j.u.c, from backport, as part of dropping support for Java 1.4.&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;It turns out that all my tests which test code that uses backport's ThreadPoolExecutor never complete. The code which supplies the executor is shown below:&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; /**&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * @return Gets the executor service. This is not publically accessible.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; */&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;ThreadPoolExecutor getExecutorService() {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (executorService == null) {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (this) {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//0, 10, 60000, ?, Integer.MAXVALUE&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;executorService =
 new ThreadPoolExecutor(0,10,&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 60000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return executorService;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Without understanding exactly why, I tried changing the corePoolSize to 1. This fixed the problem.&amp;nbsp;My question is why?&amp;nbsp;There is nothing in the JavaDoc I can see which says you must use a minimum of 1.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;And I am now worried that j.u.c. is flaky in Java 5. &amp;nbsp;Any comments from the list would be much appreciated.&lt;/div&gt;&lt;br&gt;&lt;div&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0);
 font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;div style=&quot;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2;
 word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;font style=&quot;font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font:
 none;&quot; size=&quot;3&quot; face=&quot;Helvetica&quot;&gt;Regards&lt;/font&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; min-height: 14px;&quot;&gt;&lt;br&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;font style=&quot;font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;&quot; size=&quot;3&quot; face=&quot;Helvetica&quot;&gt;Greg Luck&lt;/font&gt;&lt;/p&gt;&lt;div&gt;&lt;br class=&quot;khtml-block-placeholder&quot;&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;web: &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://gregluck.com&quot;&gt;http://gregluck.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;skype: gregrluck&lt;div&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.yahoo.com/&quot; rel=&quot;nofollow&quot;&gt;yahoo&lt;/a&gt;: gregrluck&lt;/div&gt;mobile:&amp;nbsp;+61 408 061 622&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;khtml-block-placeholder&quot;&gt;&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;

      &lt;/body&gt;&lt;/html&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19014320&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/ThreadPoolExecutor-corePoolSize-incompatibility-between-backport-and-j.u.c.-tp19011102p19014320.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19012247</id>
	<title>Re: ThreadPoolExecutor corePoolSize incompatibility between backport and j.u.c.</title>
	<published>2008-08-16T07:53:26Z</published>
	<updated>2008-08-16T07:53:26Z</updated>
	<author>
		<name>Marcelo Fukushima</name>
	</author>
	<content type="html">the problem is most likely due to a particular behavior on juc: it
&lt;br&gt;only creates threads when the queue is full. Im not sure it needs
&lt;br&gt;fixing (it suggests so) or if its already fixed in jdk7
&lt;br&gt;&lt;br&gt;On Sat, Aug 16, 2008 at 9:34 AM, Martin Buchholz &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19012247&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;martinrb@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Many bugs in ThreadPoolExecutor were fixed during late JDK6 and early JDK7.
&lt;br&gt;&amp;gt; Can you try a recent JDK7 first and see if the problem is resolved?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Martin
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Sat, Aug 16, 2008 at 4:54 AM, Greg Luck &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19012247&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gluck@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; I am looking at moving the new version of ehcache to j.u.c, from backport,
&lt;br&gt;&amp;gt;&amp;gt; as part of dropping support for Java 1.4.
&lt;br&gt;&amp;gt;&amp;gt; It turns out that all my tests which test code that uses backport's
&lt;br&gt;&amp;gt;&amp;gt; ThreadPoolExecutor never complete. The code which supplies the executor is
&lt;br&gt;&amp;gt;&amp;gt; shown below:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;/**
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;* @return Gets the executor service. This is not publically accessible.
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; ThreadPoolExecutor getExecutorService() {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (executorService == null) {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized (this) {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //0, 10, 60000, ?, Integer.MAXVALUE
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; executorService = new ThreadPoolExecutor(0,10,
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;60000, TimeUnit.MILLISECONDS, new
&lt;br&gt;&amp;gt;&amp;gt; LinkedBlockingQueue());
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return executorService;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Without understanding exactly why, I tried changing the corePoolSize to 1.
&lt;br&gt;&amp;gt;&amp;gt; This fixed the problem. My question is why? There is nothing in the JavaDoc
&lt;br&gt;&amp;gt;&amp;gt; I can see which says you must use a minimum of 1.
&lt;br&gt;&amp;gt;&amp;gt; And I am now worried that j.u.c. is flaky in Java 5. &amp;nbsp;Any comments from the
&lt;br&gt;&amp;gt;&amp;gt; list would be much appreciated.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Greg Luck
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; web: &lt;a href=&quot;http://gregluck.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gregluck.com&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; skype: gregrluck
&lt;br&gt;&amp;gt;&amp;gt; yahoo: gregrluck
&lt;br&gt;&amp;gt;&amp;gt; mobile: +61 408 061 622
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; Concurrency-interest mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19012247&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; Concurrency-interest mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19012247&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;[]'s
&lt;br&gt;Marcelo Takeshi Fukushima
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19012247&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/ThreadPoolExecutor-corePoolSize-incompatibility-between-backport-and-j.u.c.-tp19011102p19012247.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19011304</id>
	<title>Re: ThreadPoolExecutor corePoolSize incompatibility between backport and j.u.c.</title>
	<published>2008-08-16T05:34:14Z</published>
	<updated>2008-08-16T05:34:14Z</updated>
	<author>
		<name>Martin Buchholz-3</name>
	</author>
	<content type="html">Many bugs in ThreadPoolExecutor were fixed during late JDK6 and early JDK7.
&lt;br&gt;Can you try a recent JDK7 first and see if the problem is resolved?
&lt;br&gt;&lt;br&gt;Martin
&lt;br&gt;&lt;br&gt;On Sat, Aug 16, 2008 at 4:54 AM, Greg Luck &amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19011304&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gluck@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I am looking at moving the new version of ehcache to j.u.c, from backport,
&lt;br&gt;&amp;gt; as part of dropping support for Java 1.4.
&lt;br&gt;&amp;gt; It turns out that all my tests which test code that uses backport's
&lt;br&gt;&amp;gt; ThreadPoolExecutor never complete. The code which supplies the executor is
&lt;br&gt;&amp;gt; shown below:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;/**
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;* @return Gets the executor service. This is not publically accessible.
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; ThreadPoolExecutor getExecutorService() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (executorService == null) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized (this) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //0, 10, 60000, ?, Integer.MAXVALUE
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; executorService = new ThreadPoolExecutor(0,10,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;60000, TimeUnit.MILLISECONDS, new
&lt;br&gt;&amp;gt; LinkedBlockingQueue());
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return executorService;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Without understanding exactly why, I tried changing the corePoolSize to 1.
&lt;br&gt;&amp;gt; This fixed the problem. My question is why? There is nothing in the JavaDoc
&lt;br&gt;&amp;gt; I can see which says you must use a minimum of 1.
&lt;br&gt;&amp;gt; And I am now worried that j.u.c. is flaky in Java 5. &amp;nbsp;Any comments from the
&lt;br&gt;&amp;gt; list would be much appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Greg Luck
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; web: &lt;a href=&quot;http://gregluck.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gregluck.com&lt;/a&gt;&lt;br&gt;&amp;gt; skype: gregrluck
&lt;br&gt;&amp;gt; yahoo: gregrluck
&lt;br&gt;&amp;gt; mobile: +61 408 061 622
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; Concurrency-interest mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19011304&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19011304&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/ThreadPoolExecutor-corePoolSize-incompatibility-between-backport-and-j.u.c.-tp19011102p19011304.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19011102</id>
	<title>ThreadPoolExecutor corePoolSize incompatibility between backport and j.u.c.</title>
	<published>2008-08-16T04:54:53Z</published>
	<updated>2008-08-16T04:54:53Z</updated>
	<author>
		<name>gregluck</name>
	</author>
	<content type="html">&lt;html&gt;&lt;body style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;&lt;div&gt;I am looking at moving the new version of ehcache to j.u.c, from backport, as part of dropping support for Java 1.4.&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;It turns out that all my tests which test code that uses backport's ThreadPoolExecutor never complete. The code which supplies the executor is shown below:&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; /**&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * @return Gets the executor service. This is not publically accessible.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; */&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;ThreadPoolExecutor getExecutorService() {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (executorService == null) {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;synchronized (this) {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//0, 10, 60000, ?, Integer.MAXVALUE&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;executorService = new ThreadPoolExecutor(0,10,&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 60000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return executorService;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Without understanding exactly why, I tried changing the corePoolSize to 1. This fixed the problem.&amp;nbsp;My question is why?&amp;nbsp;There is nothing in the JavaDoc I can see which says you must use a minimum of 1.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;webkit-block-placeholder&quot;&gt;&lt;/div&gt;&lt;div&gt;And I am now worried that j.u.c. is flaky in Java 5. &amp;nbsp;Any comments from the list would be much appreciated.&lt;/div&gt;&lt;br&gt;&lt;div apple-content-edited=&quot;true&quot;&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; &quot;&gt;&lt;div style=&quot;word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; &quot;&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px&quot;&gt;&lt;font face=&quot;Helvetica&quot; size=&quot;3&quot; style=&quot;font: 12.0px Helvetica&quot;&gt;Regards&lt;/font&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px&quot;&gt;&lt;br&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px&quot;&gt;&lt;font face=&quot;Helvetica&quot; size=&quot;3&quot; style=&quot;font: 12.0px Helvetica&quot;&gt;Greg Luck&lt;/font&gt;&lt;/p&gt;&lt;div&gt;&lt;br class=&quot;khtml-block-placeholder&quot;&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;web: &lt;a href=&quot;http://gregluck.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gregluck.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;skype: gregrluck&lt;div&gt;yahoo: gregrluck&lt;/div&gt;mobile:&amp;nbsp;+61 408 061 622&lt;/div&gt;&lt;div&gt;&lt;br class=&quot;khtml-block-placeholder&quot;&gt;&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;br&gt;&lt;/body&gt;&lt;/html&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19011102&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/ThreadPoolExecutor-corePoolSize-incompatibility-between-backport-and-j.u.c.-tp19011102p19011102.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19000770</id>
	<title>Re: Doubt on happens-before and I/O operations.</title>
	<published>2008-08-15T08:13:55Z</published>
	<updated>2008-08-15T08:13:55Z</updated>
	<author>
		<name>Mark Thornton</name>
	</author>
	<content type="html">Fabio Cechinel Veronez wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello all,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a doubt (maybe a dummy one) about happens-before relation and
&lt;br&gt;&amp;gt; I/O operations.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In the following example code.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 01: class FileItem {
&lt;br&gt;&amp;gt; 02: &amp;nbsp; &amp;nbsp; private final File target;
&lt;br&gt;&amp;gt; 03: &amp;nbsp; &amp;nbsp; private volatile boolean written = false;
&lt;br&gt;&amp;gt; 04:
&lt;br&gt;&amp;gt; 05: &amp;nbsp; &amp;nbsp; public FileItem(File target) {
&lt;br&gt;&amp;gt; 06: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.target = target;
&lt;br&gt;&amp;gt; 07: &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt; 08:
&lt;br&gt;&amp;gt; 09: &amp;nbsp; &amp;nbsp; public void initialize() throws IOException {
&lt;br&gt;&amp;gt; 11: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (written)
&lt;br&gt;&amp;gt; 12: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&lt;br&gt;&amp;gt; 13: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OutputStream out = new FileOutputStream(target);
&lt;br&gt;&amp;gt; 14: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&lt;br&gt;&amp;gt; 15: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte[] content = // retrieves the content from somewhere ...
&lt;br&gt;&amp;gt; 16: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.write(content);
&lt;br&gt;&amp;gt; 17: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } finally {
&lt;br&gt;&amp;gt; 18: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.close();
&lt;br&gt;&amp;gt; 19: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt; 20: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; written = true;
&lt;br&gt;&amp;gt; 21: &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt; 22:
&lt;br&gt;&amp;gt; 23: &amp;nbsp; &amp;nbsp; public InputStream stream() throws IOException {
&lt;br&gt;&amp;gt; 24: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!written)
&lt;br&gt;&amp;gt; 25: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new IllegalStateException(&amp;quot;unwritten data&amp;quot;);
&lt;br&gt;&amp;gt; 26: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return new FileInputStream(target);
&lt;br&gt;&amp;gt; 27: &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt; 28: }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is it safe to say that once a Thread X reachs line 26 the content was
&lt;br&gt;&amp;gt; completely written into the 'target' file or is it possible to have
&lt;br&gt;&amp;gt; any reordering concerning the write on 'written' field (line 20) and
&lt;br&gt;&amp;gt; the output operation?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks in advance.
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;/div&gt;It s possible for two threads (or more) to be simultaneously executing 
&lt;br&gt;lines 13 - 20. The first one to reach line 20 will set written to true, 
&lt;br&gt;but the second thread will still be writing data. So the file may be 
&lt;br&gt;incomplete or may contain multiple copies of the data. I would not 
&lt;br&gt;recommend using volatile in this way.
&lt;br&gt;&lt;br&gt;Mark Thornton
&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19000770&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Doubt-on-happens-before-and-I-O-operations.-tp19000254p19000770.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-19000254</id>
	<title>Doubt on happens-before and I/O operations.</title>
	<published>2008-08-15T07:32:07Z</published>
	<updated>2008-08-15T07:32:07Z</updated>
	<author>
		<name>Fabio Cechinel Veronez</name>
	</author>
	<content type="html">Hello all,
&lt;br&gt;&lt;br&gt;I have a doubt (maybe a dummy one) about happens-before relation and
&lt;br&gt;I/O operations.
&lt;br&gt;&lt;br&gt;In the following example code.
&lt;br&gt;&lt;br&gt;01: class FileItem {
&lt;br&gt;02: &amp;nbsp; &amp;nbsp; private final File target;
&lt;br&gt;03: &amp;nbsp; &amp;nbsp; private volatile boolean written = false;
&lt;br&gt;04:
&lt;br&gt;05: &amp;nbsp; &amp;nbsp; public FileItem(File target) {
&lt;br&gt;06: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.target = target;
&lt;br&gt;07: &amp;nbsp; &amp;nbsp; }
&lt;br&gt;08:
&lt;br&gt;09: &amp;nbsp; &amp;nbsp; public void initialize() throws IOException {
&lt;br&gt;11: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (written)
&lt;br&gt;12: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&lt;br&gt;13: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OutputStream out = new FileOutputStream(target);
&lt;br&gt;14: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&lt;br&gt;15: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte[] content = // retrieves the content from somewhere ...
&lt;br&gt;16: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.write(content);
&lt;br&gt;17: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } finally {
&lt;br&gt;18: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.close();
&lt;br&gt;19: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;20: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; written = true;
&lt;br&gt;21: &amp;nbsp; &amp;nbsp; }
&lt;br&gt;22:
&lt;br&gt;23: &amp;nbsp; &amp;nbsp; public InputStream stream() throws IOException {
&lt;br&gt;24: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!written)
&lt;br&gt;25: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new IllegalStateException(&amp;quot;unwritten data&amp;quot;);
&lt;br&gt;26: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return new FileInputStream(target);
&lt;br&gt;27: &amp;nbsp; &amp;nbsp; }
&lt;br&gt;28: }
&lt;br&gt;&lt;br&gt;Is it safe to say that once a Thread X reachs line 26 the content was
&lt;br&gt;completely written into the 'target' file or is it possible to have
&lt;br&gt;any reordering concerning the write on 'written' field (line 20) and
&lt;br&gt;the output operation?
&lt;br&gt;&lt;br&gt;Thanks in advance.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Fabio Cechinel Veronez
&lt;br&gt;Bacharel em Ciências da Computação - UFSC
&lt;br&gt;Sun Certified Programmer For The Java 2 Platform 1.4
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=19000254&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Doubt-on-happens-before-and-I-O-operations.-tp19000254p19000254.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-18956786</id>
	<title>concurrency-interest now archived on MarkMail</title>
	<published>2008-08-12T20:53:34Z</published>
	<updated>2008-08-12T20:53:34Z</updated>
	<author>
		<name>Brian Goetz-3</name>
	</author>
	<content type="html">The concurrency-interest list is now archived using the most excellent 
&lt;br&gt;MarkMail mail navigator, developed by Jason Hunter of MarkLogic.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://concurrency.markmail.org/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://concurrency.markmail.org/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18956786&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/concurrency-interest-now-archived-on-MarkMail-tp18956786p18956786.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-18952602</id>
	<title>Re: Single producer, single consumer: unexpected delays for producer</title>
	<published>2008-08-12T13:42:14Z</published>
	<updated>2008-08-12T13:42:14Z</updated>
	<author>
		<name>Gregg Wonderly-2</name>
	</author>
	<content type="html">Daniel Harvey wrote:
&lt;br&gt;&amp;gt; Having tested today, I found that performing:
&lt;br&gt;&amp;gt; for (;;) queue.take();
&lt;br&gt;&amp;gt; causes very little more contention that the best scenario, and much less 
&lt;br&gt;&amp;gt; than when the socket.write() is being performed.
&lt;br&gt;&lt;br&gt;Have you tried putting another queue in place to send the writes off to another 
&lt;br&gt;thread? &amp;nbsp;This would let you have more than one thread doing encodes() and might 
&lt;br&gt;actually allow some overlapping I/O and CPU too, which will be a throughput 
&lt;br&gt;improvement.
&lt;br&gt;&lt;br&gt;I also didn't see whether you had used CTRL-\ or kill -3 &amp;lt;jvmpid&amp;gt; to get some 
&lt;br&gt;stack traces to see if they revealed the threads always &amp;quot;stuck&amp;quot; at the same 
&lt;br&gt;spot, or perhaps a &amp;quot;waiting to lock&amp;quot; state that might indicate, better, what the 
&lt;br&gt;contentious resource is.
&lt;br&gt;&lt;br&gt;Gregg Wonderly
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18952602&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Single-producer%2C-single-consumer%3A-unexpected-delays-for-producer-tp18894104p18952602.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-18951185</id>
	<title>Re: Single producer, single consumer: unexpected delays for producer</title>
	<published>2008-08-12T11:55:51Z</published>
	<updated>2008-08-12T11:55:51Z</updated>
	<author>
		<name>Daniel Harvey-4</name>
	</author>
	<content type="html">Having tested today, I found that performing:
&lt;br&gt;for (;;) queue.take();
&lt;br&gt;causes very little more contention that the best scenario, and much &amp;nbsp;
&lt;br&gt;less than when the socket.write() is being performed.
&lt;br&gt;&lt;br&gt;On Aug 11, 2008, at 8:50 PM, David Holmes wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Dan,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Your second case isn't a continuous take() because it does:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ByteBuffer bytes = encoder.encode(chars);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; that might take sufficient time for the producer to produce the &amp;nbsp;
&lt;br&gt;&amp;gt; next item
&lt;br&gt;&amp;gt; (or two) with no contention.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; That's why I said that I would expect:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; for(;;) queue.take();
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; to also cause maximum contention.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; David
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt;&amp;gt; From: Daniel Harvey [mailto:&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18951185&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dharvey@...&lt;/a&gt;]
&lt;br&gt;&amp;gt;&amp;gt; Sent: Tuesday, 12 August 2008 10:48 AM
&lt;br&gt;&amp;gt;&amp;gt; To: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18951185&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dholmes@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; Cc: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18951185&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; Subject: Re: [concurrency-interest] Single producer,single consumer:
&lt;br&gt;&amp;gt;&amp;gt; unexpected delays for producer
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I'm not sure whether the queue size is non-zero in the fast case,
&lt;br&gt;&amp;gt;&amp;gt; though I will test this tomorrow and report back. But something
&lt;br&gt;&amp;gt;&amp;gt; doesn't make sense here because in the second case - &amp;nbsp;the continuous
&lt;br&gt;&amp;gt;&amp;gt; take() one - there should be an even greater likelihood of
&lt;br&gt;&amp;gt;&amp;gt; encountering a non-empty queue... I really feel like the issue has to
&lt;br&gt;&amp;gt;&amp;gt; be the socket write interfering with the thread-signaling of the
&lt;br&gt;&amp;gt;&amp;gt; existence of a new message to process: I'm fairly sure that I could
&lt;br&gt;&amp;gt;&amp;gt; add other time-taking calculations to the consumer thread (in place
&lt;br&gt;&amp;gt;&amp;gt; of the socket.write() ) and they wouldn't slow down the producer.
&lt;br&gt;&amp;gt;&amp;gt; I'll add something like this tomorrow and see whether my assessment
&lt;br&gt;&amp;gt;&amp;gt; is accurate.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The following isn't a very elegant solution, and it might hammer the
&lt;br&gt;&amp;gt;&amp;gt; CPU too much, but I have experimented with having the consumer do a
&lt;br&gt;&amp;gt;&amp;gt; periodic sending of a batch of messages, then sleeping and checking
&lt;br&gt;&amp;gt;&amp;gt; for new messages every few ms (rather than waiting), and repeating.
&lt;br&gt;&amp;gt;&amp;gt; With this approach there's no signal between threads and I think the
&lt;br&gt;&amp;gt;&amp;gt; producer operates much faster (even with the necessary
&lt;br&gt;&amp;gt;&amp;gt; synchronization). Of course I am adding latency, but if throughput is
&lt;br&gt;&amp;gt;&amp;gt; the bottom line, it might be a useable solution.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; -Dan
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; On Aug 11, 2008, at 8:29 PM, David Holmes wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Dan,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 3) I put some code in to keep track of how many messages are
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; typically in the queue when the consumer thread finishes it's &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; take(),
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; and it is typically 0... ie the majority (around 80-90%) of the &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; time
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; a single message is being removed from the queue.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Okay so that explains the contention. The producer is expending &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; effort
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; acquiring two locks and waking up the producer.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; that's still a big difference... specifically:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; for (;;) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 	CharBuffer chars = CharBuffer.wrap(queue.take());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 	ByteBuffer bytes = encoder.encode(chars);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 	socketChannel.write(bytes);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; causes queue.offer(message) to take 3 times longer to execute &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; than if
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; the consumer executes:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; for (;;) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 	CharBuffer chars = CharBuffer.wrap(queue.take());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 	ByteBuffer bytes = encoder.encode(chars);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Can I assume that in the fast case the queue size is not normally
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; zero? If
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; so my theory here is that when the consumer uses the socketChannel
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; it is
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; introducing additional contention with the prodcuer that keeps the
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; producer
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; and conumer effectively in lock-step:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - consumer blocks on take()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - producer gets item and does offer() and has to wakeup consumer
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - consumer processes item and uses resources needed by producer
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - producer is blocked or delayed getting next item
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - consumer calls take() again and blocks
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - producer produces and calls offer() and has to wakeup consumer
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; - repeat
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; However in that case I would expect:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; for(;;) queue.take();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; to also impose maximum contention with the producer.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; David
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18951185&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Single-producer%2C-single-consumer%3A-unexpected-delays-for-producer-tp18894104p18951185.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-18950855</id>
	<title>lock acquire/release order in CHM.size()</title>
	<published>2008-08-12T11:52:48Z</published>
	<updated>2008-08-12T11:52:48Z</updated>
	<author>
		<name>Tim Eck</name>
	</author>
	<content type="html">Just a mild curiosity of mine that folks on this list might have insight
&lt;br&gt;into...
&lt;br&gt;&lt;br&gt;When operations like size() on j.u.c.ConcurrentHashMap have to resort to
&lt;br&gt;locking, the locks are acquired and released like so:
&lt;br&gt;&lt;br&gt;&amp;nbsp; for (int i = 0; i &amp;lt; segments.length; ++i) 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; segments[i].lock();
&lt;br&gt;&amp;nbsp; /* ... */ 
&lt;br&gt;&amp;nbsp; for (int i = 0; i &amp;lt; segments.length; ++i)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; segments[i].unlock();
&lt;br&gt;&lt;br&gt;The curious bit is that the last lock obtained is not the first lock
&lt;br&gt;released. I'm not suggesting there is anything wrong with that, but I was
&lt;br&gt;wondering if there is a specific rationale for that? I suppose two threads
&lt;br&gt;going through those loops would be less serialized since one thread could
&lt;br&gt;start acquiring in lock step with the other thread doing the unlocks. 
&lt;br&gt;&lt;br&gt;thanks
&lt;br&gt;-tim
&lt;br&gt;_______________________________________________
&lt;br&gt;Concurrency-interest mailing list
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18950855&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cs.oswego.edu/mailman/listinfo/concurrency-interest&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/lock-acquire-release-order-in-CHM.size%28%29-tp18950855p18950855.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-18936626</id>
	<title>Re: Single producer, single consumer: unexpected delays for producer</title>
	<published>2008-08-11T17:50:40Z</published>
	<updated>2008-08-11T17:50:40Z</updated>
	<author>
		<name>David Holmes-3</name>
	</author>
	<content type="html">Dan,
&lt;br&gt;&lt;br&gt;Your second case isn't a continuous take() because it does:
&lt;br&gt;&lt;br&gt;ByteBuffer bytes = encoder.encode(chars);
&lt;br&gt;&lt;br&gt;that might take sufficient time for the producer to produce the next item
&lt;br&gt;(or two) with no contention.
&lt;br&gt;&lt;br&gt;That's why I said that I would expect:
&lt;br&gt;&lt;br&gt;for(;;) queue.take();
&lt;br&gt;&lt;br&gt;to also cause maximum contention.
&lt;br&gt;&lt;br&gt;David
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: Daniel Harvey [mailto:&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18936626&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dharvey@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Tuesday, 12 August 2008 10:48 AM
&lt;br&gt;&amp;gt; To: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18936626&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dholmes@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Cc: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18936626&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;concurrency-interest@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Subject: Re: [concurrency-interest] Single producer,single consumer:
&lt;br&gt;&amp;gt; unexpected delays for producer
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'm not sure whether the queue size is non-zero in the fast case,
&lt;br&gt;&amp;gt; though I will test this tomorrow and report back. But something
&lt;br&gt;&amp;gt; doesn't make sense here because in the second case - &amp;nbsp;the continuous
&lt;br&gt;&amp;gt; take() one - there should be an even greater likelihood of
&lt;br&gt;&amp;gt; encountering a non-empty queue... I really feel like the issue has to
&lt;br&gt;&amp;gt; be the socket write interfering with the thread-signaling of the
&lt;br&gt;&amp;gt; existence of a new message to process: I'm fairly sure that I could
&lt;br&gt;&amp;gt; add other time-taking calculations to the consumer thread (in place
&lt;br&gt;&amp;gt; of the socket.write() ) and they wouldn't slow down the producer.
&lt;br&gt;&amp;gt; I'll add something like this tomorrow and see whether my assessment
&lt;br&gt;&amp;gt; is accurate.
&lt;br&gt;&amp