title: Create 2 threads and communicate between them
body: <p>I want to make a background task in one thread and send information from that thread to another thread which runs the main program and update the information each period of time.</p>
  
  <p>Thread1:</p>
  
  <pre><code>public void doTask()
  {
      // ...
      someData = ...;
  }
  </code></pre>
  
  <p>Thread2:</p>
  
  <pre><code>SwingUtilities.invokeLater(new Runnable()
  {
      public void run()
      {
          new MainFrame(someData);
      }
  });
  </code></pre>
  
  <p>How could I achieve this in java?</p>