title: visibility of side effects when creating and joining threads
body: <p>When are writes that are performed by one thread visible to a different thread when there are no synchronized blocks and no volatile variables? Here is a simplified quicksort example:</p>
  
  <pre><code>int middle = partitionForTheFirstTime(array);
  
  Thread t = new Thread(new Quicksorter(array, 0, middle - 1));
  Thread u = new Thread(new Quicksorter(array, middle + 1, array.size - 1));
  
  t.start()
  u.start();
  
  t.join();
  u.join();
  </code></pre>
  
  <p>(For the sake of simplicity, assume that the two "worker threads" do not spawn any additional threads.)</p>
  
  <p>Does joining with the two threads guarantee that the current thread sees all their side effects?</p>
  
  <hr>
  
  <p>On a related note, what would happen if I created the threads <em>before</em> the initial partitioning?</p>
  
  <pre><code>Quicksorter a = new Quicksorter();
  Quicksorter b = new Quicksorter();
  
  Thread t = new Thread(a);
  Thread u = new Thread(b);
  
  int middle = partitionForTheFirstTime(array);
  
  a.setParameters(array, 0, middle - 1);
  b.setParameters(array, middle + 1, array.size - 1);
  
  t.start()
  u.start();
  
  t.join();
  u.join();
  </code></pre>
  
  <p>Will the two threads be able to see the side effects caused by <code>partitionForTheFirstTime()</code>? In other words, does <em>creating</em> a Thread incur a happens-before relationship, or does <em>starting</em> a Thread?</p>