<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>HHHHq ~ Hack</title>
  <link>http://www.hhhhq.org/blog/</link>
  <description>Words and what-have-you. Geekery, for sure.</description>
  <language>en</language>
  <copyright>James Royalty</copyright>
  <lastBuildDate>Thu, 08 May 2008 03:31:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>Office voyeurism</title>
    <link>http://www.hhhhq.org/blog/2008/05/07/1210217460000.html</link>
    
      
        <description>
          &lt;p&gt;I came across the &lt;a href=&#034;http://www.officesnapshots.com/&#034;&gt;Office Snapshots&lt;/a&gt; site today.&amp;nbsp; It&#039;s a blog where people submit photos of their office.&amp;nbsp; It&#039;s primarily tech companies.&amp;nbsp; Here are a few I felt like commenting on: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href=&#034;http://www.officesnapshots.com/category/pixar/&#034;&gt;Pixar&lt;/a&gt;:&amp;nbsp; What the hell are those little houses?&amp;nbsp; Looks cool!&lt;/li&gt;
    &lt;li&gt;&lt;a href=&#034;http://www.officesnapshots.com/category/threadless/&#034;&gt;Threadless&lt;/a&gt;:&amp;nbsp; Nice industrial feel.&amp;nbsp; I love the artwork.&amp;nbsp; It looks very Chicago.&amp;nbsp; (Which is a good thing!)&lt;/li&gt;
    &lt;li&gt;&lt;a href=&#034;http://www.officesnapshots.com/category/netflix/&#034;&gt;Netflix&lt;/a&gt;:&amp;nbsp; I guess the movie images and posters are cool, but the exterior looks like a Quality Inn.&lt;/li&gt;
    &lt;li&gt;&lt;a href=&#034;http://www.officesnapshots.com/category/microsoft/&#034;&gt;Microsoft&lt;/a&gt;:&amp;nbsp; Checkout the Macs in one of those snaps.&amp;nbsp; I guess it&#039;s the Mac Office group?&amp;nbsp; Very nice feel though.&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=&#034;http://www.officesnapshots.com/category/bliptv/&#034;&gt;Blip.tv&lt;/a&gt;:&amp;nbsp; Honorable mention as they are around the corner from us!&amp;nbsp; Nice kitchen, too.&lt;/li&gt;
&lt;/ul&gt;
And for grins, here&#039;s a shot of the Pando office.&amp;nbsp; We are celebrating hitting a P2P efficiency milestone.&amp;nbsp; With 30 year old port!&lt;br /&gt;
&lt;br /&gt;
&lt;a title=&#034;Pando Offices by jlroyalty, on Flickr&#034; href=&#034;http://www.flickr.com/photos/jroyalty/2049629903/&#034;&gt;&lt;img width=&#034;500&#034; height=&#034;375&#034; alt=&#034;Pando Offices&#034; src=&#034;http://farm3.static.flickr.com/2015/2049629903_fc24908903.jpg&#034; /&gt;&lt;/a&gt;
        </description>
      
      
    
    
    
    <comments>http://www.hhhhq.org/blog/2008/05/07/1210217460000.html#comments</comments>
    <guid isPermaLink="true">http://www.hhhhq.org/blog/2008/05/07/1210217460000.html</guid>
    <pubDate>Thu, 08 May 2008 03:31:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Thread interruption strangeness under Apple&#039;s Java6</title>
    <link>http://www.hhhhq.org/blog/2008/04/09/1207763040000.html</link>
    
      
        <description>
          &lt;p&gt;
I came across some odd thread behavior under Apple&#039;s Java6 on Leopard.  I know it&#039;s still in &#034;developer preview&#034; state, but at Pando, we rely on Java6 -- under Linux, NIO performance is &lt;span style=&#034;font-style: italic;&#034;&gt;much better&lt;/span&gt; than Java5 -- and I develop on Mac. :)  In the end, &lt;a href=&#034;http://landonf.bikemonkey.org/static/soylatte/&#034;&gt;SoyLatte&lt;/a&gt; came to my rescue (which I recently stopped using because it was causing problems with Eclipse).  Read on to see how and why...
&lt;/p&gt;

&lt;p&gt;
&lt;span style=&#034;font-weight: bold;&#034;&gt;The issue and the rescue&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
To start, here&#039;s a chunk of code that&#039;s core to the issue:
&lt;/p&gt;
&lt;pre&gt;
public static void main( String[] args ) throws Exception {
  Thread t = new Thread(
    new Runnable() {
      public void run() {
        while ( !Thread.currentThread().isInterrupted() )
          ; // doing something interesting
      }
    }
  );

  t.start();
  Thread.sleep( 5000 ); // sleep on main thread
  t.interrupt();
  t.join();
}
&lt;/pre&gt;
&lt;p&gt;
Basically, I&#039;m creating a new thread with a do-nothing task (Runnable) inside.  The task loops forever as long as its owning thread hasn&#039;t been interrupted.  This is a pretty standard idiom for tasks that don&#039;t invoke any methods that throw InterruptedException(s).  After I start the thread and sleep for five seconds, I try to interrupt the thread then join it.  (Remember that join()&#039;ing a thread will cause the calling thread (the main() method in this case) to block until the joined thread terminates.)  The expected behavior after t.join() is that main() terminates.  Under Apple&#039;s Java6 that ain&#039;t the case!
&lt;/p&gt;
&lt;p&gt;
I tested with &lt;span style=&#034;font-style: italic;&#034;&gt;build 1.6.0_04-dp-b06-110&lt;/span&gt; of Apple&#039;s Java6 (the latest).  Even if I change &lt;code&gt;Thread.currentThread().isInterrupted()&lt;/code&gt; to &lt;code&gt;Thread.interrupted()&lt;/code&gt; (which is not a good idea, normally) it still won&#039;t terminate.
&lt;/p&gt;
&lt;p&gt;
Now, under &lt;span style=&#034;font-style: italic;&#034;&gt;build 1.5.0_13-b05-237&lt;/span&gt; of Apple&#039;s Java5, the thread terminates as expected.  Just for grins I tested on a few other OSes and they exhibited the correct behavior.  Here&#039;s a breakdown of the versions I tried.
&lt;/p&gt;
&lt;p&gt;
Correct behavior on
&lt;ul&gt;&lt;li&gt;Windows XP:   &lt;span style=&#034;font-style: italic;&#034;&gt;build 1.6.0_01-b06&lt;/span&gt; (Sun JVM)
&lt;/li&gt;&lt;li&gt;Linux:  &lt;span style=&#034;font-style: italic;&#034;&gt;build 1.6.0_02-b05&lt;/span&gt; (Sun JVM)&lt;/li&gt;&lt;li&gt;OS X:  &lt;span style=&#034;font-style: italic;&#034;&gt;build 1.5.0_13-b05-237&lt;/span&gt; (Apple&#039;s Java5)
&lt;/li&gt;&lt;li&gt;OS X:  &lt;span style=&#034;font-style: italic;&#034;&gt;build 1.6.0_03-p3-landonf_03_feb_2008_02_12-b00&lt;/span&gt; (SoyLatte)
&lt;/li&gt;&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
Wait!  I said SoyLatte came to the rescue didn&#039;t I?!  Well, if you use the &lt;span style=&#034;font-style: italic;&#034;&gt;client-mode VM&lt;/span&gt; then SoyLatte &lt;span style=&#034;font-style: italic;&#034;&gt;does work&lt;/span&gt;.  By client-mode I mean starting Java like:
&lt;/p&gt;
&lt;blockquote&gt;&lt;code&gt;java -client ...&lt;/code&gt;&lt;/blockquote&gt;
&lt;p&gt;
You get the server-mode VM by default.  Unfortunately Apple&#039;s Java6 is still broken even in client-mode.  Ugh Apple!  Please release a real Java6 or let Sun do it!
&lt;/p&gt;
&lt;p&gt;
&lt;span style=&#034;font-weight: bold;&#034;&gt;A full test case&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
If you want to see the problem for yourself just compile and run the following test case.
&lt;/p&gt;
&lt;pre&gt;
public class ThreadTest {
    public static void main( String[] args ) throws Exception {
        
        Runnable r = null;

        if ( args.length == 0 || &#034;isInterrupted&#034;.equals( args[0] ) ) {
            r = new Runnable() {
                    public void run() {
                        System.out.println( &#034;-- Thread using Thread.currentThread().isInterrupted()&#034; );
                        while ( !Thread.currentThread().isInterrupted() )
                            ;
                        System.out.println( &#034;-- Thread is done.&#034; );
                    }
                };
        }
        else if ( &#034;interrupted&#034;.equals( args[0] ) ) {
            r = new Runnable() {
                    public void run() {
                        System.out.println( &#034;-- Thread using Thread.interrupted()&#034; );
                        while ( !Thread.interrupted() )
                            ;
                        System.out.println( &#034;-- Thread is done.&#034; );
                    }
                };
        }
        else {
            System.out.println( &#034;Usage: ThreadTest [isInterrupted|interrupted]&#034; );
            return;
        }
            
  
        Thread t = new Thread( r );

        System.out.println( &#034;Starting thread.&#034; );
        t.start();
        Thread.sleep( 5000 );
        System.out.println( &#034;Interrupting thread.&#034; );
        t.interrupt();
        System.out.println( &#034;Joining thread.&#034; );
        t.join();
    }
}
&lt;/pre&gt;
        </description>
      
      
    
    
    
    <comments>http://www.hhhhq.org/blog/2008/04/09/1207763040000.html#comments</comments>
    <guid isPermaLink="true">http://www.hhhhq.org/blog/2008/04/09/1207763040000.html</guid>
    <pubDate>Wed, 09 Apr 2008 17:44:00 GMT</pubDate>
  </item>
  
  <item>
    <title>P4P at Pando</title>
    <link>http://www.hhhhq.org/blog/2008/04/09/1207762860000.html</link>
    
      
        <description>
          &lt;p&gt;
I posted a write up today on &lt;a href=&#034;http://www.pandoblog.com/&#034;&gt;Pandoblog.com&lt;/a&gt; about P4P.  Check it out:  &lt;a href=&#034;http://www.pandoblog.com/?p=261&#034;&gt;P4P Behind the Scenes, Part 1&lt;/a&gt;.  The other part is coming soon.
&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.hhhhq.org/blog/2008/04/09/1207762860000.html#comments</comments>
    <guid isPermaLink="true">http://www.hhhhq.org/blog/2008/04/09/1207762860000.html</guid>
    <pubDate>Wed, 09 Apr 2008 17:41:00 GMT</pubDate>
  </item>
  
  </channel>
</rss>
