title: Java trying to use Lambda expressions with Runnable to pass parameters in multi-threading tasking
body: <p>Basically I'm trying to add a <em>runnable</em> class to a <strong>tasking threading class</strong> of my own which <em>executes</em> these tasks on a different thread, I need to pass the parameters to the <em>runnable</em> object, but I'm having trouble passing strings as the compiler tells:</p>
  
  <p>"Local variable receiver defined in an enclosing scope must be final or effectively final"</p>
  
  <pre><code>String message = networkMessage.getString();
  Game.getInstance().addGameTask(new Runnable() {
              @Override
              public void run() {
                  Game.getInstance().playerTalk(player.getId(), message);
              }
  });
  </code></pre>
  
  <p>I tried using <strong>Lambda with Runnable</strong> to do something as simpler as:</p>
  
  <pre><code>Runnable r = () -&gt; Game.getInstance().playerTalk(player.getId(), mode, receiver, channelId, message);
  </code></pre>
  
  <p>But the compiler will say the same error.</p>
  
  <p>In C# I would come up with something as simple as:</p>
  
  <pre><code>Game.AddGameTask(() =&gt; { Game.PlayerTalk(_player.Id, message, mode, receiver, channelId); });
  </code></pre>
  
  <p>What can I attempt to achieve something as simple as that? It's task is supposed to be for a game server, so I need to add these "tasks" to an external thread for better functioning and performance.</p>
  
  <p>What is wrong?</p>