Java passing value to new object
<p>Is it possible to pass the value for i into the new thread object?</p>

<p>Current code:</p>

<pre><code>int cores = 4;
final int n = 10000;
static double sum = 0.0;

Thread[] threads = new Thread[cores];

for (int i = 0; i &lt; cores; i++)
{
    threads[i] = new Thread(new Runnable() {
        public void run() {
            for (int j = i * (n / cores); j &lt; (i + 1) * N / P; j++) {
                double x = (j + 0.5) * step;
                sum += 4.0 / (1.0 + x * x);
            }
        }
    });
}
</code></pre>

<p>Regards</p>
