title: SwingUtilities method param contains entire method body?
body: <p>I've been reading over the SwingUtilities.invokeLater() method, and I understand in large part its purpose. When dealing with GUI components, all actions on these components need to be done on the same Event thread to avoid races, etc.</p>
  
  <p>However, and what I think many questions have failed to expand on, is how the code actually works? Looking at it:</p>
  
  <pre><code>SwingUtilities.invokeLater(new Runnable()
  {
      public void run()
      {
          //method body code
      }
  );
  </code></pre>
  
  <p>The question I have is, how is this working? We are passing the invokeLater() method a new Runnable obj (which I thought Runnable was an interface anyway, how are we instantiating a constructor <code>new Runnable()</code>?)   and then <em>attaching a whole method body with it inside a method call</em>: <code>{//Method body code});</code>. How is that possible? I've never seen a method take in an entire method body as one of its parameters.</p>
  
  <p>When I try to replicate this with my own methods, I get errors indicating that I cannot supply entire method bodies within a method parameter. Thus, I come back to my initial question of how this <em>actually works</em>. Perhaps I am overthinking/overlooking, but any help is greatly appreciated.</p>
  
  <p>Thank you.</p>