carfield.com.hk Thread.txt 2023-09-06T13:46:21Z 2023-09-06T13:46:21Z <br/>An API to get the state of a thread, but someone say it is not reliable - <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.State.html">http://java.sun.com[..]5.0/docs/api/java/lang/Thread.State.html</a> <a href="http://java.silke-wingens.de/2011/03/13/threads-states/?lang=en">http://java.silke-wingens.de/2011/03/13/threads-states/?lang=en</a> <br/><br/><a href="http://www.nabble.com/TDD-for-multi-threaded-programs-tf3627394.html#a10128844">http://www.nabble.com[..]readed-programs-tf3627394.html#a10128844</a> <br/><br/>Having said that, I have to note that using Thread#getState() is not<br/>something you can absolutely rely on as the behavior isn't guaranteed<br/>to be the same on all platforms. That is, it can be a useful tool for<br/>debugging and test-driving but not ideal for regression (unit)<br/>testing.<br/><br/>Overview of Java thread - <a href="http://java67.blogspot.hk/2014/01/10-points-about-thread-and-javalangthread-in-java.html">http://java67.blogspot.hk[..]t-thread-and-javalangthread-in-java.html</a> <br/><br/>Loom - <a href="https://webtide.com/do-looms-claims-stack-up-part-1/">https://webtide.com/do-looms-claims-stack-up-part-1/</a> <a href="https://webtide.com/do-looms-claims-stack-up-part-2/">https://webtide.com/do-looms-claims-stack-up-part-2/</a> <br/><br/>How will we debug Loom applications? - <a href="https://www.reddit.com/r/java/comments/vxvdrv/how_will_we_debug_loom_applications/">https://www.reddit.com[..]drv/how_will_we_debug_loom_applications/</a> <br/><br/>Question: Why exactly are fibers cheaper than platform threads? - <a href="https://www.reddit.com/r/java/comments/xcr66k/question_why_exactly_are_fibers_cheaper_than/">https://www.reddit.com[..]ion_why_exactly_are_fibers_cheaper_than/</a> <br/><br/>Handling Virtual Threads - <a href="https://dzone.com/articles/handling-virtual-threads">https://dzone.com/articles/handling-virtual-threads</a> <br/><br/>1. Avoid Synchronized Blocks/Methods<br/>2. Avoid Thread Pools To Limit Resource Access<br/>3. Reduce ThreadLocal Usage<br/><a href="https://dzone.com/articles/pitfalls-to-avoid-when-switching-to-virtual-thread">https://dzone.com[..]o-avoid-when-switching-to-virtual-thread</a> <br/><br/>Exploring the design of Java’s new virtual threads - <a href="https://blogs.oracle.com/javamagazine/post/java-virtual-threads">https://blogs.oracle.com/javamagazine/post/java-virtual-threads</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2023-09-06T13:46:21Z threadlocal.txt 2023-03-08T12:44:43Z 2023-03-08T12:44:43Z <br/>There is a little bit performance cost for threadlocal variable - <a href="http://software.intel.com/en-us/blogs/2011/05/02/the-hidden-performance-cost-of-accessing-thread-local-variables/">http://software.intel.com[..]ost-of-accessing-thread-local-variables/</a> <br/><br/>Look like a useful but less known API - <a href="http://crazybob.org/2006/07/hard-core-java-threadlocal.html">http://crazybob.org/2006/07/hard-core-java-threadlocal.html</a> <br/><br/>Forward up discussion - <a href="http://www.theserverside.com/news/thread.tss?thread_id=41473&asrc=EM_NNL_406677&uid=703565">http://www.theserverside.com[..]d_id=41473&asrc=EM_NNL_406677&uid=703565</a> pointing out some problems of using this technique, include similar effect of GLOBLE , possible memory leak <br/><br/>Another discussion in higher level - <a href="http://blog.objectmentor.com/articles/2007/09/04/thread-local-a-convenient-abomination">http://blog.objectmentor.com[..]04/thread-local-a-convenient-abomination</a> , Key is "An object is an abstraction of function. A thread is an abstraction of schedule" , you can read further conclusion at <a href="http://www.infoq.com/news/2007/09/confusing_uow_with_threads">http://www.infoq.com/news/2007/09/confusing_uow_with_threads</a> <br/><br/>Protential issue of using threadlocal, one is memory leak and the other is it is that local - <a href="http://blog.maxant.co.uk/pebble/2008/09/23/1222200780000.html">http://blog.maxant.co.uk/pebble/2008/09/23/1222200780000.html</a> <a href="http://www.javacodegeeks.com/2012/05/threading-stories-threadlocal-in-web.html">http://www.javacodegeeks.com[..]hreading-stories-threadlocal-in-web.html</a> <br/><a href="http://plumbr.eu/blog/how-to-shoot-yourself-in-foot-with-threadlocals">http://plumbr.eu[..]shoot-yourself-in-foot-with-threadlocals</a> <br/><br/>The beauty of the design of threadlocal, how it prevent locking and memory leaking - <a href="http://plumbr.eu/blog/how-is-threadlocal-implemented">http://plumbr.eu/blog/how-is-threadlocal-implemented</a> <br/><br/>JEP 429: Extent-Local Variables to Promote Immutability in Java - <a href="https://www.infoq.com/news/2022/09/extent-local-variables-java/">https://www.infoq.com/news/2022/09/extent-local-variables-java/</a> <br/><br/>An Introduction to Scoped Values in Java - <a href="https://foojay.io/today/an-introduction-to-scoped-values-in-java/">https://foojay.io/today/an-introduction-to-scoped-values-in-java/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2023-03-08T12:44:43Z Interrupt.txt 2022-03-19T12:00:19Z 2022-03-19T12:00:19Z <br/>Just know that interrupt() call is just setting a flag, it have to be doing IO work (like database call), or in wait() status, before the thread can really be interrupted.<br/><br/><a href="http://blogs.sun.com/roller/page/swinger?entry=swingworker_stop_that_train">http://blogs.sun.com[..]winger?entry=swingworker_stop_that_train</a> <br/><br/>Another nice explanation about interrupt, in summary:<br/><br/>What should we do when we call code that may cause an InterruptedException? Don't immediately yank out the batteries! Typically there are two answers to that question: <br/>1) Rethrow the InterruptedException from your method. This is usually the easiest and best approach. It is used by the new java.util.concurrent.* package [ <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Semaphore.html#acquire()">http://java.sun.com[..]util/concurrent/Semaphore.html#acquire()</a> ], which explains why we are now constantly coming into contact with this exception. <br/>2) Catch it, set interrupted status, return. If you are running in a loop that calls code which may cause the exception, you should set the status back to being interrupted. For example: <br/><pre>while (!Thread.currentThread().isInterrupted()) {<br/> // do something<br/> try {<br/> TimeUnit.SECONDS.sleep(1000);<br/> } catch (InterruptedException e) {<br/> Thread.currentThread().interrupt();<br/> break;<br/> }<br/>}</pre>Remember the Law of the Sabotaged Doorbell - don't just ignore interruptions, manage them properly!<br/><br/>- <a href="http://www.javaspecialists.eu/archive/Issue146.html">http://www.javaspecialists.eu/archive/Issue146.html</a> <br/><br/>Another blog explain about InterruptedException - <a href="http://www.nurkiewicz.com/2014/05/interruptedexception-and-interrupting.html">http://www.nurkiewicz.com[..]terruptedexception-and-interrupting.html</a> <br/><br/><a href="http://ocpsoft.org/regex/how-to-interrupt-a-long-running-infinite-java-regular-expression">http://ocpsoft.org[..]running-infinite-java-regular-expression</a> <br/><br/><a href="http://praveer09.github.io/technology/2015/12/06/understanding-thread-interruption-in-java/">http://praveer09.github.io[..]derstanding-thread-interruption-in-java/</a> <br/><br/>How to Stop a Java Thread Without Using Thread.stop()? - <a href="https://4comprehension.com/how-to-stop-a-java-thread-without-using-thread-stop/">https://4comprehension.com[..]a-java-thread-without-using-thread-stop/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2022-03-19T12:00:19Z primitive.txt 2022-02-05T13:05:36Z 2022-02-05T13:05:36Z <br/>Benchmark for LongAddr - <a href="http://concurrencyfreaks.blogspot.hk/2013/09/longadder-and-dclc.html">http://concurrencyfreaks.blogspot.hk[..]gspot.hk/2013/09/longadder-and-dclc.html</a> <br/><br/>If there is a concern about wasting too many memory for Atomic* wrapper class, we may consider changed to use AtomicFieldUpdater to update primitive directly - <a href="http://normanmaurer.me/blog/2013/10/28/Lesser-known-concurrent-classes-Part-1/">http://normanmaurer.me[..]/Lesser-known-concurrent-classes-Part-1/</a> <br/><br/>What exactly is 'tearing'? - <a href="https://www.reddit.com/r/java/comments/rsr8az/what_exactly_is_tearing/">https://www.reddit.com[..]comments/rsr8az/what_exactly_is_tearing/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2022-02-05T13:05:36Z Executor.txt 2021-10-06T06:16:36Z 2021-10-06T06:16:36Z <br/>Sample ResubmittingScheduledThreadPoolExecutor, the coding is nice! <a href="http://www.javaspecialists.eu/archive/Issue154.html">http://www.javaspecialists.eu/archive/Issue154.html</a> <br/><br/>Implement thread pool properly - <a href="http://www.kimchy.org/juc-executorservice-gotcha/">http://www.kimchy.org/juc-executorservice-gotcha/</a> <br/><br/>RetryExecutor - <a href="http://nurkiewicz.blogspot.hk/2013/07/asynchronous-retry-pattern.html">http://nurkiewicz.blogspot.hk[..]/2013/07/asynchronous-retry-pattern.html</a> <br/><br/>ScheduledThreadPoolExecutor corePoolSize=0 at JDK9 cause 100% CPU - <a href="https://josephmate.github.io/2021-10-03-my-bug-used-up-100cpu-or-did-it/">https://josephmate.github.io[..]1-10-03-my-bug-used-up-100cpu-or-did-it/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2021-10-06T06:16:36Z memory model.txt 2020-05-23T04:07:35Z 2020-05-23T04:07:35Z <br/>Examples of how to use volatile - <a href="http://www.ibm.com/developerworks/java/library/j-jtp06197.html">http://www.ibm.com/developerworks/java/library/j-jtp06197.html</a> <br/><br/>Related with volatile, explanation of thread safe of initalize with final / non-final variable - <a href="http://www.nabble.com/Parametric-Initialization-On%09DemandHolder-Idiom---tf4384557.html">http://www.nabble.com[..]On%09DemandHolder-Idiom---tf4384557.html</a> <br/><br/><a href="http://jeremymanson.blogspot.com/2007/08/volatile-does-not-mean-atomic.html">http://jeremymanson.blogspot.com[..]07/08/volatile-does-not-mean-atomic.html</a> <br/><a href="http://jeremymanson.blogspot.com/2009/06/volatile-arrays-in-java.html">http://jeremymanson.blogspot.com[..]com/2009/06/volatile-arrays-in-java.html</a> <br/><br/>Difference between volatile and synchronization - <a href="http://stackoverflow.com/questions/3603157/volatile-keyword-in-java-clarification">http://stackoverflow.com[..]7/volatile-keyword-in-java-clarification</a> <a href="http://javarevisited.blogspot.com/2011/06/volatile-keyword-java-example-tutorial.html">http://javarevisited.blogspot.com[..]atile-keyword-java-example-tutorial.html</a> <br/><br/><a href="http://blog.thesoftwarecraft.com/2014/07/javas-volatile-modifier.html">http://blog.thesoftwarecraft.com[..]com/2014/07/javas-volatile-modifier.html</a> <br/><br/>Explain volatile in bytecode - <a href="https://plumbr.eu/blog/understanding-volatile-via-example">https://plumbr.eu/blog/understanding-volatile-via-example</a> <br/><br/>Detail explanation - <a href="http://www.codesod.com/2015/10/30/java-multi-threading-volatile-variables-happens-before-relationship-and-memory-consistency/">http://www.codesod.com[..]ore-relationship-and-memory-consistency/</a> <br/><br/><a href="https://vmlens.com/articles/cp/java_memory_model_enables_tests/">https://vmlens.com/articles/cp/java_memory_model_enables_tests/</a> <br/><br/><a href="https://vmlens.com/articles/cp/thread_safety_definition/">https://vmlens.com/articles/cp/thread_safety_definition/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2020-05-23T04:07:35Z collections.txt 2020-03-29T10:15:44Z 2020-03-29T10:15:44Z <br/>Even though <br/><pre><br/> private List synchList = Collections.synchronizedList(new LinkedList());<br/></pre><br/>is thread safe, serialize sync List is NOT thread safe for sure. The story is, if you only synchronized the collection, and if we try to get the iterator in concurrent access environment, it will throws currencymodificationexception .<br/><br/>For collection is small, may be making defensive copy <a href="http://www.javapractices.com/Topic15.cjp">http://www.javapractices.com/Topic15.cjp</a> is good. Otherwise, in java5, there is concurrency collection. <br/><br/>reference:<br/><a href="http://jroller.com/page/jvenu?entry=collections_synchronizedlist_broken">http://jroller.com[..]ntry=collections_synchronizedlist_broken</a> <br/><a href="http://jroller.com/page/ctarrington?entry=java_collections_trivia">http://jroller.com/page/ctarrington?entry=java_collections_trivia</a> <br/><br/>Map operation, include use of FutureTask and putIfAbsent() method from ConcurrentMap. - <a href="http://www.javaspecialists.co.za/archive/newsletter.do?issue=125">http://www.javaspecialists.co.za/archive/newsletter.do?issue=125</a> <br/><br/>Other then lterate through the elements, adding and removing elements can also be problem, this article document a few good cases about that - <a href="http://rayfd.wordpress.com/2007/11/11/when-a-synchronized-class-isnt-threadsafe/">http://rayfd.wordpress.com[..]en-a-synchronized-class-isnt-threadsafe/</a> <br/><br/>Samples of using Queue.drainTo() - <a href="http://binkley.blogspot.com/2007/09/performing-fixed-amounts-of-work-with.html">http://binkley.blogspot.com[..]rforming-fixed-amounts-of-work-with.html</a> <br/><br/><a href="http://tech.puredanger.com/2009/02/28/java-7-transferqueue/">http://tech.puredanger.com/2009/02/28/java-7-transferqueue/</a> <br/><br/>Overview of blockingqueue - <a href="http://tutorials.jenkov.com/java-util-concurrent/blockingqueue.html">http://tutorials.jenkov.com[..]/java-util-concurrent/blockingqueue.html</a> <br/><br/>Simple benchmark - <a href="http://java-persistence-performance.blogspot.com/2011/03/jvm-performance-part-iii-concurrent.html">http://java-persistence-performance.blogspot.com[..]jvm-performance-part-iii-concurrent.html</a> <br/><br/>Multi-thread behaviour - <a href="http://vanillajava.blogspot.com/2011/06/thread-safety-issues-with-vector-and.html">http://vanillajava.blogspot.com[..]hread-safety-issues-with-vector-and.html</a> <br/><br/>java.util.concurrent.ConcurrentHashMap VS openhft.collections.SharedHashMap - <a href="http://openhft.blogspot.co.uk/2014/03/javautilconcurrentconcurrenthashmap-vs.html">http://openhft.blogspot.co.uk[..]autilconcurrentconcurrenthashmap-vs.html</a> <br/><br/>Why are there so many concurrent queues implementations in Java? - <a href="https://vmlens.com/articles/cp/why_so_many_queues/">https://vmlens.com/articles/cp/why_so_many_queues/</a> <br/><br/>Why hashmap is not thread safe - <a href="https://www.pixelstech.net/article/1585457836-Why-Java-HashMap-is-considered-as-thread-unsafe">https://www.pixelstech.net[..]a-HashMap-is-considered-as-thread-unsafe</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2020-03-29T10:15:44Z tutorial.txt 2020-01-28T10:48:00Z 2020-01-28T10:48:00Z <br/>Another nice tutorial set of concurrency framework - <a href="http://www.javacodegeeks.com/search/label/Concurrency">http://www.javacodegeeks.com/search/label/Concurrency</a> <br/><br/>Java concurrency, Building and testing concurrent applications for the Java platform - <a href="http://www.ibm.com/developerworks/training/kp/j-kp-concurrency/index.html">http://www.ibm.com[..]/training/kp/j-kp-concurrency/index.html</a> <br/><br/>JVM concurrency: Java and Scala concurrency basics - <a href="http://www.ibm.com/developerworks/java/library/j-jvmc1/index.html?ca=drs-">http://www.ibm.com[..]/java/library/j-jvmc1/index.html?ca=drs-</a> <br/><br/><a href="http://javarevisited.blogspot.com.au/2014/07/top-50-java-multithreading-interview-questions-answers.html">http://javarevisited.blogspot.com.au[..]reading-interview-questions-answers.html</a> <br/><br/>5 things you didn't know about ... Multithreaded Java programming - <a href="https://www.ibm.com/developerworks/library/j-5things15">https://www.ibm.com/developerworks/library/j-5things15</a> <br/><br/>266Threading Questions in Job Interviews (2/2) - <a href="https://www.javaspecialists.eu/archive/Issue266.html">https://www.javaspecialists.eu/archive/Issue266.html</a> <br/><br/>Parallel Collection Processing: Without Parallel Streams - <a href="https://4comprehension.com/parallel-collection-processing-1/">https://4comprehension.com/parallel-collection-processing-1/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2020-01-28T10:48:00Z framework.txt 2019-03-09T15:33:41Z 2019-03-09T15:33:41Z <br/><a href="https://dzone.com/articles/a-birds-eye-view-on-java-concurrency-frameworks-1">https://dzone.com[..]ye-view-on-java-concurrency-frameworks-1</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2019-03-09T15:33:41Z Contended.txt 2017-09-28T08:21:47Z 2017-09-28T08:21:47Z <br/>preventing false sharing with the @Contended annotation - <a href="https://dzone.com/articles/what-false-sharing-is-and-how-jvm-prevents-it">https://dzone.com[..]false-sharing-is-and-how-jvm-prevents-it</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2017-09-28T08:21:47Z Map.txt 2017-03-10T09:49:16Z 2017-03-10T09:49:16Z <br/>putall can cause ConcurrentModifcationException - <a href="http://cr.openjdk.java.net/~littlee/OJDK-256/webrev.00/src/share/classes/sun/management/Agent.java.sdiff.html">http://cr.openjdk.java.net[..]ses/sun/management/Agent.java.sdiff.html</a> <br/><br/>Note on writing CopyOnWrite wrapper - <a href="http://flyingspaniel.blogspot.com/2010/12/copyonwrite-wrappers.html">http://flyingspaniel.blogspot.com[..]ot.com/2010/12/copyonwrite-wrappers.html</a> <br/><br/>Sometime this is a bit difficult for Chinese to be a good programmer, recently some colleague and me discuss about the behaviour of this class and look like we have difficult understanding<br/><br/>A: ConcurrentHashMap support for locking as this is thread-safe<br/>B: ConcurrentHashMap is thread safe for read but not for write because there is no lock, we still need to have external lock to keep it thread safe. By the way, I get ConcurrentModificationException from this before.<br/>C: ConcurrentHashMap don't support for locking but they still thread safe for all operations, which is how "This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details." mentioned.<br/><br/>Too good that we can actually take a look at the source code to see what going on nowadays rather than just guessing - <a href="http://www.google.com/codesearch?client=opera&rls=en&q=ConcurrentHashMap&sourceid=opera&ie=utf-8&oe=utf-8">http://www.google.com[..]HashMap&sourceid=opera&ie=utf-8&oe=utf-8</a> By the way, this constructor is useful for a lot of concurrency access but actually not many developer notice about this - <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html#ConcurrentHashMap(int,">http://java.sun.com[..]rrentHashMap.html#ConcurrentHashMap(int,</a> float, int) <br/><br/>Lazy initialization of map values - <a href="http://artisans-serverintellect-com.si-eioswww6.com/default.asp?W122">http://artisans-serverintellect-com.si-eioswww6.com[..]ect-com.si-eioswww6.com/default.asp?W122</a> <br/><br/>HashMap.get() can cause infinite loop - <a href="http://lightbody.net/blog/2005/07/hashmapget_can_cause_an_infini.html">http://lightbody.net[..]5/07/hashmapget_can_cause_an_infini.html</a> <br/><br/>Discussing the effect of initCapacity() of HashMap in Java - <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=021171">http://saloon.javaranch.com[..]ltimatebb.cgi?ubb=get_topic&f=1&t=021171</a> <br/><br/>OpenJDK and HashMap …. Safely Teaching an Old Dog New (Off-Heap!) Tricks - <a href="http://www.infoq.com/articles/Open-JDK-and-HashMap-Off-Heap">http://www.infoq.com/articles/Open-JDK-and-HashMap-Off-Heap</a> <br/><br/>We can run search in ConcurrenctHashMap - <a href="https://dzone.com/articles/concurrenthashmap-in-java8">https://dzone.com/articles/concurrenthashmap-in-java8</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2017-03-10T09:49:16Z synchronisers.txt 2017-01-03T01:45:40Z 2017-01-03T01:45:40Z <br/>Similar to Barrier - <a href="http://tech.puredanger.com/2008/07/08/java7-phasers/">http://tech.puredanger.com/2008/07/08/java7-phasers/</a> <br/><br/>An example, show how to coordinate producer and consumer with Phaser - <a href="http://javaforu.blogspot.com/2011/08/java-7s-jucphaser-short-tutorial.html">http://javaforu.blogspot.com[..]08/java-7s-jucphaser-short-tutorial.html</a> <br/><br/>When to use CountDownLatch, Semaphore, CyclicBarrier, Exchanger and Phaser - <a href="https://codurance.com/2016/08/24/the-java-synchronisers/">https://codurance.com/2016/08/24/the-java-synchronisers/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2017-01-03T01:45:40Z Lock.txt 2016-10-06T15:58:24Z 2016-10-06T15:58:24Z <br/>ReentrantReadWriteLock - <a href="http://www-128.ibm.com/developerworks/library/j-jtp10264/index.html">http://www-128.ibm.com[..]loperworks/library/j-jtp10264/index.html</a> <br/><br/>why it suppose to be faster than VM level lock - <a href="http://osdir.com/ml/java.jsr.166-concurrency/2005-02/msg00031.html">http://osdir.com[..]sr.166-concurrency/2005-02/msg00031.html</a> and a test about it - <a href="http://mechanical-sympathy.blogspot.gr/2011/11/java-lock-implementations.html">http://mechanical-sympathy.blogspot.gr[..]r/2011/11/java-lock-implementations.html</a> <br/><br/>Samples of how to use it, and how to write test cases about it - <a href="http://www.javaspecialists.eu/archive/Issue152.html">http://www.javaspecialists.eu/archive/Issue152.html</a> <br/><br/>Some useful VM parameter to tune the locks: -XX:+EliminateLocks , -XX:+DoEscapeAnalysis , -XX:+UseBiasedLocking - <a href="http://work.tinou.com/2009/06/lock-coarsening-biased-locking-escape-analysis-for-dummies.html">http://work.tinou.com[..]locking-escape-analysis-for-dummies.html</a> <br/><br/>Discuss about 3 difference lock for Java, bias, thin and fat - <a href="http://www.javacodegeeks.com/2011/05/how-jvm-handle-locks.html">http://www.javacodegeeks.com/2011/05/how-jvm-handle-locks.html</a> <br/><br/>Why using the read lock will make lock detector fail - <a href="http://javaeesupportpatterns.blogspot.com.au/2013/01/java-concurrency-hidden-thread-deadlocks.html">http://javaeesupportpatterns.blogspot.com.au[..]concurrency-hidden-thread-deadlocks.html</a> <br/><br/>Basic of synchronization and locking - <a href="http://www.takipiblog.com/2013/08/15/5-things-you-didnt-know-about-synchronization-in-java-and-scala/">http://www.takipiblog.com[..]about-synchronization-in-java-and-scala/</a> <br/><br/>Better semaphore with striped api - <a href="http://codingjunkie.net/striped-concurrency/">http://codingjunkie.net/striped-concurrency/</a> <br/><br/>Comparing and discuss difference locking approach - <a href="http://www.javaspecialists.eu/archive/Issue215.html">http://www.javaspecialists.eu/archive/Issue215.html</a> <br/><br/>Compare performance behavior of RWLock, StampedLock and Optimistic lock - <a href="http://www.takipiblog.com/2014/05/30/java-8-stampedlocks-vs-readwritelocks-and-synchronized/">http://www.takipiblog.com[..]ocks-vs-readwritelocks-and-synchronized/</a> <br/><br/>Comparing sync and lock - <a href="http://www.rationaljava.com/2015/08/a-case-study-in-analysing-latency-lock.html">http://www.rationaljava.com[..]ase-study-in-analysing-latency-lock.html</a> <br/><br/><a href="http://vmlens.com/articles/reentrant-lock-cheat-sheet/">http://vmlens.com/articles/reentrant-lock-cheat-sheet/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2016-10-06T15:58:24Z race.txt 2016-07-05T08:29:21Z 2016-07-05T08:29:21Z <br/><a href="http://vmlens.com/articles/java-race-conditions-or-how-to-find-an-irreproducable-bug-2/">http://vmlens.com[..]-or-how-to-find-an-irreproducable-bug-2/</a> <br/><a href="http://vmlens.com/articles/detecting-java-race-conditions-with-tests-part-2/">http://vmlens.com[..]-java-race-conditions-with-tests-part-2/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2016-07-05T08:29:21Z Fork-join.txt 2015-02-20T08:06:37Z 2015-02-20T08:06:37Z <br/>Overview - <a href="http://www.infoq.com/news/2007/07/concurrency-java-se-7">http://www.infoq.com/news/2007/07/concurrency-java-se-7</a> <br/><br/>Google - <a href="http://www.google.com/search?client=opera&rls=en&q=jsr166y&sourceid=opera&ie=utf-8&oe=utf-8">http://www.google.com[..]jsr166y&sourceid=opera&ie=utf-8&oe=utf-8</a> <br/><br/>Javadoc - <a href="http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/index.html?overview-summary.html">http://gee.cs.oswego.edu[..]66ydocs/index.html?overview-summary.html</a> <br/><br/>An article with good code sample - <a href="http://www.ibm.com/developerworks/java/library/j-jtp11137.html?ca=drs-">http://www.ibm.com[..]rks/java/library/j-jtp11137.html?ca=drs-</a> <a href="http://www.theserverside.com/blogs/thread.tss?track=NL-461&ad=636686&thread_id=49104">http://www.theserverside.com[..]s?track=NL-461&ad=636686&thread_id=49104</a> <a href="http://www.infoq.com/news/2008/03/fork_join">http://www.infoq.com/news/2008/03/fork_join</a> <a href="http://www.codecommit.com/blog/scala/higher-order-fork-join-operators">http://www.codecommit.com[..]g/scala/higher-order-fork-join-operators</a> <a href="http://www.coopsoft.com/ar/ForkJoinArticle.html">http://www.coopsoft.com/ar/ForkJoinArticle.html</a> <br/><br/>Fibonacci series - <a href="http://www.javacodegeeks.com/2012/04/fork-and-join-in-java-7-jsr-166.html">http://www.javacodegeeks.com[..]/04/fork-and-join-in-java-7-jsr-166.html</a> <br/><br/>Discussion about using difference framework - <a href="http://blog.takipi.com/forkjoin-framework-vs-parallel-streams-vs-executorservice-the-ultimate-benchmark/">http://blog.takipi.com[..]-executorservice-the-ultimate-benchmark/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2015-02-20T08:06:37Z Reference.txt 2014-03-26T03:10:08Z 2014-03-26T03:10:08Z <br/>How weak and soft reference work <a href="http://www.javaspecialists.co.za/archive/Issue098.html">http://www.javaspecialists.co.za/archive/Issue098.html</a> <a href="http://javarevisited.blogspot.com.au/2014/03/difference-between-weakreference-vs-softreference-phantom-strong-reference-java.html">http://javarevisited.blogspot.com.au[..]rence-phantom-strong-reference-java.html</a> <br/><br/>Issue about weakhashmap - <a href="http://blogs.azulsystems.com/cliff/2007/08/why-weakhashmap.html">http://blogs.azulsystems.com/cliff/2007/08/why-weakhashmap.html</a> <br/><br/>When soft reference clean? - <a href="http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html">http://jeremymanson.blogspot.com[..]/07/how-hotspot-decides-to-clear_07.html</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2014-03-26T03:10:08Z pool.txt 2013-12-23T10:09:08Z 2013-12-23T10:09:08Z <br/>Demo how java 1.5 built-in thread pool work: <a href="http://blogs.sun.com/roller/page/swinger?entry=swingworker_throttling_and_monitoring">http://blogs.sun.com[..]ry=swingworker_throttling_and_monitoring</a> <br/><br/>Sample of thread pool - <a href="http://www.javaworld.com/javaworld/jw-01-2005/jw-0124-pool_p.html">http://www.javaworld.com/javaworld/jw-01-2005/jw-0124-pool_p.html</a> <br/><br/>Discussion about how to estimate threadpool size - <a href="http://www.infoq.com/articles/Java-Thread-Pool-Performance-Tuning">http://www.infoq.com/articles/Java-Thread-Pool-Performance-Tuning</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2013-12-23T10:09:08Z Double-Checked Locking.txt 2013-10-22T09:25:00Z 2013-10-22T09:25:00Z <br/>Very detailed explanation: <a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html">http://www.cs.umd.edu[..]va/memoryModel/DoubleCheckedLocking.html</a> <br/><br/>Some more information, also demo in fact not much difference for most cast: <a href="http://blogs.sun.com/roller/page/cwebster?entry=double_check_locking">http://blogs.sun.com[..]page/cwebster?entry=double_check_locking</a> <br/><br/>Even more discussion - <a href="http://www-128.ibm.com/developerworks/java/library/j-dcl.html">http://www-128.ibm.com/developerworks/java/library/j-dcl.html</a> <br/><br/>In Chinese - <a href="http://www.infoq.com/cn/articles/double-checked-locking-with-delay-initialization">http://www.infoq.com[..]hecked-locking-with-delay-initialization</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2013-10-22T09:25:00Z testing.txt 2013-09-23T10:11:40Z 2013-09-23T10:11:40Z <br/>Series of blog showing how to use JMock API to help testing MT code - <a href="http://www.google.com/cse?cx=008451033954659354866%3Ashhtresohqc&ie=UTF-8&q=JMock+and+Threads">http://www.google.com[..]shhtresohqc&ie=UTF-8&q=JMock+and+Threads</a> <br/><br/>A test for deadlock - <a href="http://cr.openjdk.java.net/~plevart/jdk8-tl/AnnotationType/fix1/webrev.01/test/java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java.sdiff.html">http://cr.openjdk.java.net[..]notationTypeDeadlockTest.java.sdiff.html</a> <a href="http://cr.openjdk.java.net/~jgish/Bug8010939-LogManager-Deadlock/test/java/util/logging/Bug8010939.java.html">http://cr.openjdk.java.net[..]t/java/util/logging/Bug8010939.java.html</a> <br/><br/>Some technique, use of SynchronousExecutorService and Events - <a href="http://alexecollins.com/content/5-tips-unit-testing-threaded-code/">http://alexecollins.com[..]ntent/5-tips-unit-testing-threaded-code/</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2013-09-23T10:11:40Z Actor.txt 2012-06-07T16:56:58Z 2012-06-07T16:56:58Z <br/>Collections from IBM - <a href="http://www.ibm.com/developerworks/training/kp/j-kp-actorconcurrency">http://www.ibm.com[..]rworks/training/kp/j-kp-actorconcurrency</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2012-06-07T16:56:58Z Join.txt 2011-11-12T18:37:44Z 2011-11-12T18:37:44Z <br/>Example of Join - <a href="http://cnapagoda.blogspot.com/2010/01/thread-join-method.html">http://cnapagoda.blogspot.com/2010/01/thread-join-method.html</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2011-11-12T18:37:44Z yield.txt 2011-09-25T01:35:12Z 2011-09-25T01:35:12Z <br/>Yield is not that reliable- <a href="http://www.azulsystems.com/blog/cliff/2011-09-23-a-pair-of-somebody-elses-concurrency-bugs">http://www.azulsystems.com[..]-pair-of-somebody-elses-concurrency-bugs</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2011-09-25T01:35:12Z monitoring.txt 2011-08-28T11:58:48Z 2011-08-28T11:58:48Z <br/>Sample code of try-sync<br/><br/><pre><br/>import sun.misc.*;<br/><br/>import java.lang.reflect.*;<br/><br/>public class MonitorUtils {<br/> private static Unsafe unsafe = getUnsafe();<br/><br/> public static boolean trySynchronize(Object monitor) {<br/> return unsafe.tryMonitorEnter(monitor);<br/> }<br/><br/> public static void unsynchronize(Object monitor) {<br/> unsafe.monitorExit(monitor);<br/> }<br/><br/> private static Unsafe getUnsafe() {<br/> try {<br/> for (Field field : Unsafe.class.getDeclaredFields()) {<br/> if (Modifier.isStatic(field.getModifiers())) {<br/> if (field.getType() == Unsafe.class) {<br/> field.setAccessible(true);<br/> return (Unsafe) field.get(null);<br/> }<br/> }<br/> }<br/> throw new IllegalStateException("Unsafe field not found");<br/> } catch (Exception e) {<br/> throw new IllegalStateException(<br/> "Could not initialize unsafe", e);<br/> }<br/> }<br/>}</pre><br/><br/><a href="http://www.javaspecialists.eu/archive/Issue194.html">http://www.javaspecialists.eu/archive/Issue194.html</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2011-08-28T11:58:48Z hint.txt 2011-06-26T16:27:08Z 2011-06-26T16:27:08Z <br/>A nice list of hints about concurrency in java - <a href="http://www.weiqigao.com/blog/2007/03/09/eric_burke_java_concurrency_by_example.html">http://www.weiqigao.com[..]c_burke_java_concurrency_by_example.html</a> <br/><br/>Testing about java parallel processing - <a href="http://embarcaderos.net/2011/01/23/parallel-processing-and-multi-core-utilization-with-java/">http://embarcaderos.net[..]ng-and-multi-core-utilization-with-java/</a> <br/><br/>Some concurrency basic information - <a href="http://blog.andrewhubbs.com/?p=107">http://blog.andrewhubbs.com/?p=107</a> <br/><br/>Tutorial of concurrency package - <a href="http://tutorials.jenkov.com/java-util-concurrent/index.html">http://tutorials.jenkov.com/java-util-concurrent/index.html</a> <br/><br/>Using Latch with Executor - <a href="http://binkley.blogspot.com/2011/06/new-shimmer-for-java-concurrency.html">http://binkley.blogspot.com[..]06/new-shimmer-for-java-concurrency.html</a> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2011-06-26T16:27:08Z AnonymousInnerClass.txt 2011-02-15T17:16:05Z 2011-02-15T17:16:05Z <br/>Here is an tricky concurrency concern in Java when using Anonymous Inner Class with ExecutorService, if you use collection from outside class, that collection actually a global variable in the Inner Class, and need to take care the issues happened in concurrency access.<br/><br/>For this class: <pre><br/>public static void main(String[] args) throws InterruptedException {<br/> ExecutorService es = Executors.newFixedThreadPool(80);<br/> final List<String> list = new ArrayList<String>();<br/> for (int i = 0; i < 100000; i++)<br/> es.execute(new Runnable() {<br/> @Override<br/> public void run() {<br/> list.add(new String());<br/> }<br/> });<br/> es.shutdown();<br/> while (true) {<br/> boolean terminated = es.awaitTermination(5, TimeUnit.SECONDS);<br/> if (terminated) {<br/> break;<br/> }<br/> }<br/> for (String string : list) {<br/> if (string == null)<br/> System.out.println("Have null");<br/> }<br/> }<br/> </pre><br/> actually same as<br/><pre><br/> private static final class RunnableImpl implements Runnable {<br/> private final List<String> mList;<br/> private RunnableImpl(List<String> list) {<br/> mList = list;<br/> }<br/> <br/> @Override<br/> public void run() {<br/> mList.add(new String());<br/> }<br/> }<br/> public static void main(String[] args) throws InterruptedException {<br/> ExecutorService es = Executors.newFixedThreadPool(80);<br/> final List<String> list = new ArrayList<String>();<br/> for (int i = 0; i < 100000; i++)<br/> es.execute(new RunnableImpl(list));<br/> /** @formatter:on */<br/> es.shutdown();<br/> while (true) {<br/> boolean terminated = es.awaitTermination(5, TimeUnit.SECONDS);<br/> if (terminated) {<br/> break;<br/> }<br/> }<br/> for (String string : list) {<br/> if (string == null)<br/> System.out.println("Have null");<br/> }<br/> }<br/></pre> <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2011-02-15T17:16:05Z