<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Weiqi Gao&#039;s Observations - concurrency tag</title>
  <link>http://www.weiqigao.com/blog/tags/concurrency/</link>
  <description>Sharing My Experience...</description>
  <language>en</language>
  <copyright>Weiqi Gao</copyright>
  <lastBuildDate>Fri, 11 May 2012 12:48:36 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  <image>
    <url>http://pebble.sourceforge.net/common/images/powered-by-pebble.gif</url>
    <title>Weiqi Gao&#039;s Observations</title>
    <link>http://www.weiqigao.com/blog/</link>
  </image>
  
  
  <item>
    <title>Eric Burke: Java Concurrency By Example</title>
    <link>http://www.weiqigao.com/blog/2007/03/09/eric_burke_java_concurrency_by_example.html</link>
    
      
        <description>
          &lt;p&gt;We had an outstanding presentation at the &lt;a href= &#034;http://www.ociweb.com/javasig/&#034; &gt;St. Louis JUG&lt;/a&gt; yesterday evening.  Eric Burke, of the &lt;a href= &#034;http://stuffthathappens.com/blog&#034; &gt;It&#039;s Just a Bunch of Stuff That Happens&lt;/a&gt; fame, gave a presentation on some of the new Java 5 and 6 concurrency features, through a series of examples.  Like in the &lt;a href= &#034;http://www.weiqigao.com/blog/2005/04/15/eric_burke_hibernate_in_60_minutes.html&#034; &gt;past&lt;/a&gt;, this is another one of those &#034;you have to be there to experience it&#034; presentations.&lt;/p&gt;

&lt;p&gt;Here&#039;s what I learned from this presentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;a href= &#034;http://www.briangoetz.com/pubs.html&#034; &gt;Java Concurrency in Practice&lt;/a&gt; book, by Brian Goetz, with Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, and Doug Lea, is a must read for anyone developing Java applications on a modern Java platform.&lt;/li&gt;
&lt;li&gt;Have you written something like this
&lt;pre style=&#034;margin-left:3em&#034;&gt;try {
  Thread.sleep(1000);
} catch (InterruptedException e) {
  // ignored
}&lt;/pre&gt;
This is completely wrong.&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;i++&lt;/tt&gt; is not atomic.&lt;/li&gt;
&lt;li&gt;The new concurrency utilities package in Java 5 and 6 is very rich.  It&#039;s worth studying in depth.&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;TimeUnit&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;CopyOnWriteArraySet&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;Use a &lt;tt&gt;ThreadFactory&lt;/tt&gt; to create threads and give them proper names instead of the default &#034;Thread-1&#034;, &#034;Thread-2&#034; and register &lt;tt&gt;UncaughtExceptionHandler&lt;/tt&gt;&#039;s.&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;Executor&lt;/tt&gt;, &lt;tt&gt;Future&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;Lock&lt;/tt&gt;, &lt;tt&gt;tryLock()&lt;/tt&gt;, &lt;tt&gt;lockInterruptibly()&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;ReadWriteLock&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;BlockingQueue&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;Here&#039;s how a thread should be written
&lt;pre style=&#034;margin-left:3em&#034;&gt;new Thread() {
  public void run() {
    while (!Thread.currentThread().isInterrupted()) {
      // do the work...
    }
  }
}&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the meta level, I think the lesson is there are so much stuff that&#039;s new in Java 5, that it&#039;s worth learning it anew.&lt;/p&gt;

&lt;hr align=&#034;center&#034; noshade=&#034;noshade&#034; size=&#034;1&#034; width=&#034;60%&#034;&gt;

&lt;p&gt;On a different topic in the post presentation chats, Eric mentioned that the latest Java 6 have many improvements over Java 5.  And if you are upgrading from Java 1.4, you might as well skip Java 5 and jump directly to Java 6&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2007/03/09/eric_burke_java_concurrency_by_example.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2007/03/09/eric_burke_java_concurrency_by_example.html</guid>
    <pubDate>Fri, 09 Mar 2007 14:15:13 GMT</pubDate>
  </item>
  
  <item>
    <title>I Need To Get That Book!</title>
    <link>http://www.weiqigao.com/blog/2006/08/09/i_need_to_get_that_book.html</link>
    
      
        <description>
          &lt;blockquote&gt;
&lt;p&gt;&lt;a href= &#034;http://www.scruffles.net/blog/archive/000178.html&#034; &gt;Bryan Young&lt;/a&gt;: I&#039;ve only made it halfway through, and I feel like the little kid in &#039;The Sixth Sense&#039; -- I see bugs everywhere.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Bryan is talking about Brian Goetz&#039;s new book &lt;a href= &#034;http://www.briangoetz.com/pubs.html&#034; &gt;Java Concurrency in Practice&lt;/a&gt;.  I have read many of Brian Goetz&#039;s columns in various web sites and have always learned something from each article.&lt;/p&gt;

&lt;p&gt;I also heard &lt;a href= &#034;http://beanman.wordpress.com/&#034; &gt;Brian Coyner&lt;/a&gt; say that the book is worth a read.&lt;/p&gt;

&lt;p&gt;I&#039;m going to get a copy of the book tomorrow.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2006/08/09/i_need_to_get_that_book.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2006/08/09/i_need_to_get_that_book.html</guid>
    <pubDate>Thu, 10 Aug 2006 04:14:46 GMT</pubDate>
  </item>
  
  <item>
    <title>The Problem With Threads</title>
    <link>http://www.weiqigao.com/blog/2006/05/16/the_problem_with_threads.html</link>
    
      
        <description>
          &lt;p&gt;&lt;em&gt;(Via &lt;a href= &#034;http://lambda-the-ultimate.org/node/1481&#034; &gt;Lambda the Ultimate&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href= &#034;http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.html&#034; &gt;Edward A. Lee&lt;/a&gt;: Many technologists are pushing for increased use of multithreading in software in order to take advantage of the predicted increases in parallelism in computer architectures. In this paper, I argue that this is not a good idea.&lt;/p&gt;
&lt;/blockquote&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2006/05/16/the_problem_with_threads.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2006/05/16/the_problem_with_threads.html</guid>
    <pubDate>Tue, 16 May 2006 12:15:32 GMT</pubDate>
  </item>
  
  </channel>
</rss>

