title: Passing parameter to Java Thread
body: <pre><code>Thread t = new Thread(new Runnable() { public void run() {} });
  </code></pre>
  
  <p>I'd like to create a thread this way. How can I pass parameters to the <code>run</code> method if possible at all?</p>
  
  <p><strong>Edit</strong>: To make my problem specific, consider the following code segment:</p>
  
  <pre><code>for (int i=0; i&lt; threads.length; i++) {
      threads[i] = new Thread(new Runnable() {public void run() {//Can I use the value of i in the method?}});
  }
  </code></pre>
  
  <p>Based on Jon's answer it won't work, since <code>i</code> is not declared as <code>final</code>. </p>