title: How Runnable is created from Java8 lambda
body: <p>I've come across some code which I'm struggling to understand despite a bit of reading.  There is a call to a method which takes in two args, one of which is a Runnable.  Rather than passing in a Runnable object though there is a lambda.</p>
  
  <p>For example:</p>
  
  <pre>
  public class LambdaTest {
  
      private final Lock lock = new ReentrantLock();
  
      @Test
      public void createRunnableFromLambda() {
          Locker.runLocked(lock, () -> {
              System.out.println("hello world");
          });
      }
  
      public static class Locker {
          public static void runLocked(Lock lock, Runnable block) {
              lock.lock();
              try {
                  block.run();
              } finally {
                  lock.unlock();
              }
          }
      }
  }
  </pre>
  
  <p>So my question is, can you explain how a Runnable is created from the lambda, and also please could someone explain the syntax <strong>()</strong> -> {}.  Specifically, what do the () brackets mean?</p>
  
  <p>thanks.</p>