title: How to transfer method call to another thread with some short code?
body: <p>I have a Gui class that is supposed to update GUI, which runs in Swing main thread and must be accessed from that thread. I have some methods to change what is displayed in Gui. Some of those methods may be called from other threads. I ended up with this code:</p>
  
  <pre><code>   public void changeSomethingInGui() {
       change button enabled state for example...
     }
     public void changeSomethingInGuiAsync() {
       SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
           Gui.this.changeSomethingInGui();
         }
       });
     }
  </code></pre>
  
  <p>This really sucks, there's like 5 more similar methods and this strategy will require many lines of totally useless (for the reader) code.</p>
  
  <p>There's no worst way of handling callback than the java's, that's for sure, but isn't there some workaround? For example in C++, I can post methods as callbacks to threads like this (using boost library):</p>
  
  <pre><code>guiThreadClass.queueAction(boost::bind(Gui::DoSomethingInGui, guiInstance, param1, param2));
  </code></pre>
  
  <p>One single line. That would make it 3 lines for every method in my class - much more comfortable. </p>